I am trying to get the USART on a Mega8 to talk to my P.C. and
I'm having problems getting reliable data transmission. Sometimes
the data is correct and sometimes I get junk.
I am using a STK500 system and have the internal clock set for 3.696 MHZ
which is supposed to be a magic setting for 0% error on USART
transmission. However, when I scope the XTAL jumper I see 3.7014 MHZ
.This is about .1% error and should be OK I think.
I am using the code from AVR306 with the exception of adding the URSEL
bit for the shared register on the Mega8. I've checked the init section of
AVR303 which is targeted at the Mega8 and except for the interupt enable
bit it's the same. Since I'm using polled mode I think this should be OK too.
To go from reliable data to junk and back to reliable I cycle the power on
the STK500. About 1 out of 6 times the data is good. Scoping data bits
in both modes I see that the data rate is 19200 in both cases. I have tried
2 different P.C.'s as the data terminals with the same result.