Hello! I am trying to establish serial communication between the PC and the AT89C5131 at a baudrate of 9600. The microcontroller has a clock frequency of 16 MHz. According to the baud rate calculator by Keil, 0xFC is the value to be loaded into the BRL register for generating baud rate closest to 9600. However this is not exact, so mostly garbage values are being transmitted. I have attached my code below; please help me figure out if there is any other way to ensure the transmission and reception does not involve unwanted data. The 8051 echoes whatever is sent from the computer - the code is a slightly modified version of something I found on the Atmel website.
#include "reg_c51.h" char uart_data; void main (void) { SCON = 0x50; BDRCON &=0xEC; BDRCON |=0x0C; BRL=0xFC; ES = 1; EA = 1; BDRCON |=0x10; while(1); } void serial_IT(void) interrupt 4 { if (RI == 1) { RI = 0; uart_data = SBUF; SBUF = uart_data; } else TI = 0; }
please help me figure out if there is any other way to ensure the transmission and reception does not involve unwanted data
use a "baudrate crystal" e.g. 11.0592MHz
Or an even better solution. Since this thread is tagged as an ARM thread - consider selecting a suitable ARM processor and enjoy big nice 32-bit prescale + baudrate + fractional + PLL + peripherial clocking registers and mix and match crystal frequencies, core frequencies, peripherial frequencies, baudrates as needed.
"According to the baud rate calculator by Keil, 0xFC is the value to be loaded into the BRL register"
But the Keil 8051 Baud Rate Calculator - http://www.keil.com/c51/baudrate.asp - only covers the use of the standard 8051's Timer1 and Timer2. It doesn't cover any "BRL register"
www.8052.com/tutser.phtml
So what do you mean ?
Thank you, I think this is what I'm going to do.
Unfortunately, I don't have a choice in the controller that I'm using. But the controller I'm using the "AT89C5131A-L" allows me to change my crystal frequency.
The BRL register is the Baud rate Reload register, it is an 8-bit register used exclusively for Baud rate generation and works as an 8-bit autoreload timer. It's a part of the Internal Baud rate generator in the 8051.
www.atmel.in/.../doc4338.pdf
I think he understands that, but what baud rate do you end up generating, and what's the percentage of error compared to the desired frequency? Can that be improved by using a different crystal?
It's a part of the Internal Baud rate generator in the 8051
That register might be in the ATMEL part, but it's not a standard 8051 SFR.
But the Keil 8051 Baud Rate Calculator .... only covers the use of the standard 8051's Timer1 and Timer2. It doesn't cover any "BRL register"
but, since all UART comms are divided from the crystal freq, it can still be used with some care.