Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20688

BASCOM-AVR : USART, Baud rate, and Crystal : NEWTOPIC

$
0
0
Hi All; i'm using a 12MHz crystal and a ATmega164p and have written a simple program to work at 57600 baud-- the program is nothing more than printing the letter U continuously ( no CR LF) so that i get a consistent waveform of 10101010 output, easily seen and measured on an o'scope. At 57600 baud life is beautiful-- i measure 17.42us for the pulse width (i.e the "1" in the binary waveform stream) when the baud rate should give me 1/57600 = 17.36us; just about a 0.3% difference between measured and calculated; lo and behold when i input the output from the ATmega 164p into an RS232 serial port ( the board has a MAX3232 on it) i get the letter U screaming accross the screen-- everything perfect. now the problem-- i now change the baud rate to 115200 and nothing works, i checked the pulse width and its 9.44us when it should be (1/115200) 8.68us a difference of 8% !!!!-- so i should expect the RS232 NOT to work; which is exactly what i see, random characters, gibberish, screaming accross the screen Here's the question-- is there some command/setting that i can use in BASCOM to change something about how the crystal is divided/used by the ATmel164p so that i can be <1% difference between the buad rate and the waveform so that RS232 will work? Alternatively what new crystal frequency should i change to so that both 57600 and 115200 will work? Thanks in advance [b:b1ea7ab9dd][color=red:b1ea7ab9dd](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.6 )[/b:b1ea7ab9dd][/color:b1ea7ab9dd]

Viewing all articles
Browse latest Browse all 20688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>