Porting V-USB to Atmega48 / 88 / 168 - important hint
Posted: Sun Jun 19, 2011 4:10 pm
I run into problems with porting HIDKeys and some other projects from ATmega8 to ATmega48 and could not succeed with hints from other posters. I finaly solved the problem with some important changes at the end of usbconfig.h. The trick was:
ATMEL changed some register names with Atmega48/88/168, so V-USB needs these changes to let the driver enable external interrupt INT0. Wondering why I got no error messages before changing this like for TCCR0 and TIFR (has to be TCCR0B and TIFR0). My Atmega48 works fine with 12 MHz, 5 V from USB and 68 Ohm / 3,6V zener diodes at the data lines.
Of course donĀ“t forget to uncheck the CLKDIV8-fuse and it is a good idea to use the latest usbdrv from 11-2008 even with the older projects.
Code: Select all
#define USB_INTR_CFG EICRA /* not MCUCR */
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
/* #define USB_INTR_CFG_CLR 0 */
#define USB_INTR_ENABLE EIMSK /* not GIMSK */
/* #define USB_INTR_ENABLE_BIT INT0 */
#define USB_INTR_PENDING EIFR /* not GIFR */
/* #define USB_INTR_PENDING_BIT INTF0 */
ATMEL changed some register names with Atmega48/88/168, so V-USB needs these changes to let the driver enable external interrupt INT0. Wondering why I got no error messages before changing this like for TCCR0 and TIFR (has to be TCCR0B and TIFR0). My Atmega48 works fine with 12 MHz, 5 V from USB and 68 Ohm / 3,6V zener diodes at the data lines.
Of course donĀ“t forget to uncheck the CLKDIV8-fuse and it is a good idea to use the latest usbdrv from 11-2008 even with the older projects.