Baud 1200

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!

Reply to
terry
Loading thread data ...

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?

Reply to
Magnus J

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

Reply to
Unbeliever

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

Reply to
terry

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
Reply to
Leon Heller

I have tried another sample but it still happens!

Reply to
terry

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

Reply to
Paul Burke

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.