Google

Jul 6, 2008

Trouble with Atmega32's USART BaudRate ?

If there is some problem with usart baudRate then.

I want to set the USART Baud Rate to 9600 bps using 8-N-1 config.

The atmega32 is running on its internal 1 MHz oscillator. While configuring the USART I have used:

UBRR = 6

As per the table given on the Page 165 of atmega32's datasheet.

The table has two columns for the given baudrate for U2X=0 and U2X=1... Can you tell me what does this mean? And what is U2X is referring to?

I have interfaced an Xbee transceiver by Maxstream with the USART which is set to work on 9600 bps but apparently the data is not being Tx/Rx correctly. Any inputs?

Answer :

Well, let's tell if you use 1MHz internal crystal, you will have about 7% error which is not reliable at all. If you want a ZERO error rate you need to use an external crystal which is a multiple of 1200. For example a 11.0592 MHz is a multiply of 1200


( 11059200 / 1200 = 9216 )

you may understand why this is so.

Anyway, this is configuration for UART port of ATMEGA32 ( no interrupt )

UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x06;


you may check it in ATMEGA32 datasheet. You will surely understand how these values are selected.

In another note , as a starter I suggest you to work with CodeVision AVR. You can write ANSI C in this compiler.
But if you are going to go forward I suggest you to use IAR AVR. That is the only C++ compiler for AVR. It would be amazing if you want to write C++ codes. Also you can use it's JTAG debugger which is a miracle. You can connect a JTAGICE to your micro and you can place breakepoints on lines you want your program to be break and the you can check EVERYTHING at breakpoints. For example you want to see when you arrive to a line in your program what is the value of X. You will simply drag and drop X to the watch list and you will see the value of X. You can even see you memory IN CIRCUIT.


You might be also interested in:

:: Answers of Microprocessor(8085) & Electronics FAQ
:: The 8085 Microprocessor Architecture Microprocessors & Interfacing
:: How to add two binary numbers without carry

No comments: