Hi Guys,
I tried to seek help from the Arduino forum but no luck.
http://forum.arduino.cc/index.php?topic=266485.0
I have been running a ChibiOS/NIL on an ATmega32u4. It was super easy to implement my code. The moment I remove the USB and plug it back in, I break the bootloader! I am finish developping my code so I want a standalone module so I plug it in 12V. The moment I do that, I corrupt the bootloader. When developping, the USB cable is plug in the Arduino and I can upload my code and to all my test. The moment I remove the USB and try to apply external power again(USB, 5V, 12V, Vin, etc) it can not start. I have to reloader the bootloader, I connect to the serial port of the bootloader and reload the blink sketch.
I do not get this problem with the ATmega328. The problem is the same with the Arduino Micro.
I suppose that would be related to ATmega32u4 bootloader (Caterina). I think it might be ISR or watchdog that is continually resetting.
Here is a video of what is happening.
https://www.youtube.com/watch?v=lVY_4SOJBtE
Thank you for you help.
ATmega32u4 freeze at powerup
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- Posts: 3
- Joined: Wed Sep 17, 2014 4:07 am
Re: ATmega32u4 freeze at powerup
To be more specific, I am not using avr gcc. I am compiling and uploading with Arduino IDE. I have try ChibiOS_AVR, NilRTOS and leOS/leOS2 libraries.
The bootloader is the Caterina that is use with the Arduino Micro, Arduino Leonardo and the Esplora.
The bootloader is the Caterina that is use with the Arduino Micro, Arduino Leonardo and the Esplora.
Re: ATmega32u4 freeze at powerup
This category of strange behavior tends to drive a developer insane
Two things I can think of:
1. did you compile with the correct arch for Caterina? According to the source I found here there's at least some requirement to compile with a #define __AVR_ATmega32U4__ in your code. Maybe you forgot it?
2. When flashing, does the programmer also set the fuses? Check that you flash with the correct target.
Two things I can think of:
1. did you compile with the correct arch for Caterina? According to the source I found here there's at least some requirement to compile with a #define __AVR_ATmega32U4__ in your code. Maybe you forgot it?
2. When flashing, does the programmer also set the fuses? Check that you flash with the correct target.
-
- Posts: 3
- Joined: Wed Sep 17, 2014 4:07 am
Re: ATmega32u4 freeze at powerup
BOOM!
Found my bug Fred!
I deleted all my serial println and was able to pin point my mistake!!
I wanted to make a #define DEBUG where I could remove all my serial printf from my code instantly! To save memory.
Then I use this
What killed the code is this: while (!Serial) {}
Thank you Fred.
Found my bug Fred!
I deleted all my serial println and was able to pin point my mistake!!
I wanted to make a #define DEBUG where I could remove all my serial printf from my code instantly! To save memory.
Code: Select all
#define DEBUG 1
#ifdef DEBUG
void SerialDebug(const char* sMsg){
Serial.println(sMsg);
}
#endif
Then I use this
Code: Select all
SerialDebug("thread1 thread initialize");
What killed the code is this: while (!Serial) {}
Code: Select all
void setup() {
#ifdef DEBUG
Serial.begin(9600);
// wait for USB Serial
while (!Serial) {} <======= I deleted this line!
SerialDebug("9600 baud rate");
#endif
// Start Nil RTOS.
nilSysBegin();
SerialDebug("Define is set");
}
Thank you Fred.
Who is online
Users browsing this forum: No registered users and 12 guests