Page 1 of 1

First pass through USART RX handler takes a long time

Posted: Sat Jul 14, 2012 6:46 am
by JetForMe
This is on an 8 MHz ATmega644A. I'm sending 115k bps serial data to the MCU. If I put a millisecond or more between characters, it seems to receive very reliably. But if I send at full speed, it's very unreliable.

I twiddle an LED and use an o'scope to time how long it sits inside the RX interrupt handler. The first time, after sitting idle for some time, it seems to take a lot longer than subsequent times.

Could this be the case? I also am suspicious that my o'scope is missing the falling edge of the pulse, and the rising edge of the next pulse, and making two trips through the ISR look like one. But it's a decent Tektronix scope, and it never seems to miss on the subsequent interrupts, so I don't think that's it.

It could also be the baud generator just has too much error in it. I bought a different crystal which should give me zero-error baud.

Re: First pass through USART RX handler takes a long time

Posted: Sat Jul 14, 2012 9:17 am
by JetForMe
Well, while I'm still not sure I understand what I'm seeing regarding the ISR timing, I've solved my overall read problem. Seems to be due to baud rate error, despite 115200 being only 3.1% off for my clock frequency. I upped it all to 250k (0% error), and it's working flawlessly.

Pity I wasted so long on this.