Baud 1200

Nov 29, 2004 6 Replies

Hi,



I used ATMega16 UART to communicate with a target device which is of baud 1200 but failed. I then tried to communicate the UART with PC COM Port and terminal software. I found the communication is OK when the baud is from 115200 down to 2400. But straight characters appear when the baud rate turns to 1200.



My baud setting function is:



void uartSetBaudRate(u32 baudrate) { u16 bauddiv=F_CPU/baudrate/16L-1; outb(UBRRL, bauddiv); outb(UBRRH, bauddiv>>8); }



Do anyone has my similar problem? The MCU clock speed is 7.3728MHz.



Thanks!


Isn't it the UBRRL write that triggers the change in the baudrategenerator so you should change the order of writing to UBRRH and UBRRL?

From the data sheet: "The UBRRH contains the four most significant bits, and the UBRRL contains the 8 least significant bits of the USART baud rate. Ongoing transmissions by the transmitter and receiver will be corruptedif the baud rate is changed. Writing UBRRL will trigger an immediate update of the baud rate prescaler."

i.e. UBBRL should be written second.

Cheers,

Alf

Have tried to write UBRRH firstly and then UBRRL secondly but still failed.:{

Check your oscillator frequency (with a counter), it might be slightly out. I vaguely remember from somewhere that this can be more important with low baud rates.

Leon

Leon Heller, G1HSM http://www.geocities.com/leon_heller http://www.kasamba.com/viewExpert.asp?conMemID=105725&Catid=1111&banID=2100

How about making it transmit continuously, putting a scope on the output, and looking at what's actually coming out? Continuous stream of

0x55s or 0xAAs should give something easily visible. And if nothing comes out, change the values you are putting in the Baud registers until something does, and work from there.

Paul Burke

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required