I have been struggling with UART comm problems on an ATmega1284p (5V, 20 MHz crystal, date code 0805). The symptom looks like code runaway; control will jump into my bootloader at random times. The bootloader always displays the cause for entry by analyzing MCUSR; when the problem appears, MCUSR flag bits are all cleared.
I can force the problem to occur by:
1. Setting up UART0 (57600, 8N1), Tx ONLY is enabled (Rx and UART interrupts are disabled).
2. Writing a known pattern to a large array in RAM.
3. Disabling interrupts [cli();].
4. Sitting in a loop that tests all cells of the array for the correct value and displays any errors detected. The number of times through the loop is displayed on the UART (using Hyperterm), so I see a constantly incrementing count to 0xffff, then a wrap back to 0.
Here's the problem: If I let the above program run with no interaction on the UART, the program works perfectly. The loop counter increments, then rolls, forever (or so), and the error counter is always 0.
However, if I hold down a key on the keyboard and force Hyperterm to send a stream of chars to the UART, the program will consistently crash back to the bootloader, which reports MCUSR as 0. The timing of the crash is not predictable, but it always happens, generally within about 30 seconds.
This behavior happens on two different '1284p devices, both with date codes of 0805.
The only reference to something like this that I can find on the web is here: http://uzebox.org/forums/viewtop...
Has anyone else seen this? If so, how did you fix it?