Atmega8535 OK / Atmega328p FAIL
Re: Atmega8535 OK / Atmega328p FAIL
I started to switch from ATmega168 with USBaspLoader to the ATmega328p and I always get an unrecognized USB device.
I run all my devices with 12MHz and program via avrdude from the makefile without problems so far.
Thanks for all tips in this thread so far !
It did follow the recommendation to treat the 328P chip 100% like the 168, but this fails.
I also changed the interrupt vector as recommended by Detlev in usbdrvasm.S
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
# define USB_INTR_VECTOR INT0_vect /* 30Dec09 SIG_INTERRUPT0 viewtopic.php?f=8&t=2663 */
# endif
But now compiling and flashing (successfully) as 328P or as 168 still fails, with an unrecognized USB device.
What else needs to be changed to run USBaspLoader onto an 328P with my case 12MHz ?
I run all my devices with 12MHz and program via avrdude from the makefile without problems so far.
Thanks for all tips in this thread so far !
It did follow the recommendation to treat the 328P chip 100% like the 168, but this fails.
I also changed the interrupt vector as recommended by Detlev in usbdrvasm.S
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
# define USB_INTR_VECTOR INT0_vect /* 30Dec09 SIG_INTERRUPT0 viewtopic.php?f=8&t=2663 */
# endif
But now compiling and flashing (successfully) as 328P or as 168 still fails, with an unrecognized USB device.
What else needs to be changed to run USBaspLoader onto an 328P with my case 12MHz ?
-
- Rank 1
- Posts: 28
- Joined: Wed Sep 30, 2009 3:36 am
- Location: Osaka, Japan
- Contact:
Re: Atmega8535 OK / Atmega328p FAIL
I started to switch from ATmega168 with USBaspLoader to the ATmega328p and I always get an unrecognized USB device.
I'm not sure if you solved your issue with the bootloader, but one thing to make sure of is that you're putting the bootloader in the correct place. I just spent a few hours struggling to figure out why HIDBootloader wasn't working on my 328p when it was working just fine on my 168, and it turned out that I simply needed to make sure that when I compiled, I put my code in the 328p's bootloader section, which starts at a much higher address than the 168. For a 1024 word bootloader section on the 328p, the bootloader needs to be compiled such that it starts at 7800 instead of 3800 for the 168. Hope it helps someone!
Re: Atmega8535 OK / Atmega328p FAIL
he bootloader needs to be compiled such that it starts at 7800 instead of 3800 for the 168
Could some one explain how exactly you do that? I get options to pick from not a way to enter it manually? 2048 puts it at 3800? Is there a ways to define BOOTLOADER_ADDRESS avr studio to override the gui? I'm using the make option not a file, guessing if I made a mFile I could do it in there?
According to my AVR studio with the 328p selected I get 4 options.
Boot Flash size=256 words start address=$3F00
Boot Flash size=512 words start address=$3E00
Boot Flash size=1024 words start address=$3C00
Boot Flash size=2048 words start address=$3800
Last edited by ulao on Tue Aug 31, 2010 11:56 pm, edited 1 time in total.
Re: Atmega8535 OK / Atmega328p FAIL
The figures from AVR Studio are in words (16 bits = 2 bytes) while gcc's values and thus the values specified in the Makefile are in bytes.
Re: Atmega8535 OK / Atmega328p FAIL
So I should chose $3800 in avr studio, yet still no luck? What else could I have missed? I did try the latest code.
My avr fuses I find the closest match are
0xFF extended
0xD8 High
0xDF low
My avr fuses I find the closest match are
0xFF extended
0xD8 High
0xDF low
Last edited by ulao on Tue Aug 31, 2010 11:41 pm, edited 2 times in total.
Re: Atmega8535 OK / Atmega328p FAIL
No. Half of 7800 is 3C00. And you should choose a boot section size of 1024 words (= 2048 bytes).
Re: Atmega8535 OK / Atmega328p FAIL
but how can you do that if they are on the same line? In avr studio I only get the 4 options.
Boot Flash size=256 words start address=$3F00
Boot Flash size=512 words start address=$3E00
Boot Flash size=1024 words start address=$3C00
Boot Flash size=2048 words start address=$3800
Will I need to use an mFile and will the defines override the gui?
Boot Flash size=256 words start address=$3F00
Boot Flash size=512 words start address=$3E00
Boot Flash size=1024 words start address=$3C00
Boot Flash size=2048 words start address=$3800
Will I need to use an mFile and will the defines override the gui?
Re: Atmega8535 OK / Atmega328p FAIL
You want
Boot Flash size=1024 words start address=$3C00
That's 2048 BYTES of boot flash size starting at the correct position.
Boot Flash size=1024 words start address=$3C00
That's 2048 BYTES of boot flash size starting at the correct position.
Re: Atmega8535 OK / Atmega328p FAIL
Wow, then I must be confusing myself here. I figure Boot Flash size was in bytes since it didnt have the '$' but now I see the "word" . Either way I have tried them all. What about the hint that a change should be made here
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
# ifdef INT0_vect
# define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector
# else
# define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector
# endif
# endif
Re: Atmega8535 OK / Atmega328p FAIL
You don't need to change anything here, the code you quote already takes care of the p suffix devices.
BTW: The "$" does not mean words or bytes here, it means that the value is in hex, not in dec.
BTW: The "$" does not mean words or bytes here, it means that the value is in hex, not in dec.
Re: Atmega8535 OK / Atmega328p FAIL
Well, thx for all the help Christian. I certainly understand things better now However I do not understand why every thing works when flash to a 168 and not a 328p.
I have the new code that handles the pico bug.
I have the right fuses FF,DA,DF. ( not 100% on the Brown-out but disabled works on 168 ( tried all other options ) )
Tried multiple chips.
Tried burning as if it were a 168 ( dont agree with that but didnt help )
BootRst is check ( at least this is needed for 168 )
Set MCU to 328p in project settings.
Didn't read any changes needed in the Bootloader code.
I continue to get usb device not recognized on this chip. Any more ideas?
I have the new code that handles the pico bug.
I have the right fuses FF,DA,DF. ( not 100% on the Brown-out but disabled works on 168 ( tried all other options ) )
Tried multiple chips.
Tried burning as if it were a 168 ( dont agree with that but didnt help )
BootRst is check ( at least this is needed for 168 )
Set MCU to 328p in project settings.
Didn't read any changes needed in the Bootloader code.
I continue to get usb device not recognized on this chip. Any more ideas?
Re: Atmega8535 OK / Atmega328p FAIL
You can first try to load it as normal application at address 0 instead of the boot area. Don't know which boot loader you use, but USBaspLoader has an optional define "NO_FLASH_WRITE". If you set it, it's compiled as normal application which can be loaded at address 0.
Re: Atmega8535 OK / Atmega328p FAIL
Sorry I'm using BootloadHID. I can use any v-usb example on the 328p just fine, only the bootloader gives me troubles. I didnt see NO_FLASH_WRITE in there.
Re: Atmega8535 OK / Atmega328p FAIL
The define in bootloadHID is "TEST_MODE". Did you check the over-all code size? It might exceed the 2k of the boot area.
Re: Atmega8535 OK / Atmega328p FAIL
2k as in Program and data together?
I removed all debug code to shrink it down a bit.
I did not see a define for TEST_MODE, but I do see the #if for it, so I set TEST_MODE 1 and tried to flash without the bootrst fuse bit. This did not seem to help, does this imply its related to code, since all other apps seem to flash correctly?
Code: Select all
AVR Memory Usage
----------------
Device: atmega328p
Program: 1946 bytes (5.9% Full)
(.text + .data + .bootloader)
Data: 59 bytes (2.9% Full)
(.data + .bss + .noinit)
I did not see a define for TEST_MODE, but I do see the #if for it, so I set TEST_MODE 1 and tried to flash without the bootrst fuse bit. This did not seem to help, does this imply its related to code, since all other apps seem to flash correctly?