Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Baud Rate for AT89C51

Status
Not open for further replies.

Maverickmax

Advanced Member level 1
Joined
Dec 6, 2004
Messages
404
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,298
Activity points
3,689
8051 baud rate calculator

Hi

Specification for AT89C51
Baud rate - 9600
Clock - 12MHz
SMOD - 1
TH1 - 0xF9

so is my code correct?

Code:
void serial_send()
{
SCON=0x50;
TMOD=0x20;
TH1=0xF9;
TR1=1;
TI=1;
}

Maverick Max
 

12mhz baud rate

No; you can't get proper 9600 bauds with acceptable error on a 8051 at 12MHz.

What you set now is 12000000/12/32/7=4464 Baud, which has an error of over 6% to 4800 Bauds. The acceptable error is around 3%. You could possibly get a good 9600Baud on a 8052, using Timer2 for baudrate generation.

See the datasheets/tutorials/etc. and also Keil's baudrate calculator at:
https://www.keil.com/c51/baudrate.asp

wek
 

maximum baud rate for at89c51

Yes you are right. But closer not precise.
The baudrate coming is 4,464.29 * 2 = 8928.58
And you want 9600!

Why are you using 12MHz crystal? I will recomend you to use 11.0592MHz crystal. It will give you an exact baudrate.

Use the following formula if SMOD = 1
Code:
TH1 = (256 - (XTAL_12000000 / (16 * 12 * baudrate)));
Use the following formula if SMOD = 0
Code:
TH1 = (256 - (XTAL_12000000 / (32 * 12 * baudrate)));

eg. 11059200/(32*12) = 28800 incase of 12MHZ it comes 62500
now 28800/9600 = 3
thus 256 - 3 = 253 decimal and 0XFD in hex as TH1 load count.

For above example clear SMOD bit
In the same way you can derive the chart for different baudrates at different crystal frequencies.

If you are not following what I am saying, then use this
http://www.keil.com/c51/baudrate.asp
for tutorials
**broken link removed**

Regards
Sarang
 

8951 baud rate

Sarang,

SMOD is not set in the presented code, so I see no reason to assume it is set (it is cleared by default).

wek
 

atmel baudrate calculator

Hi Wek, this SMOD - 1 is from the assumption
Maverickmax said:
Specification for AT89C51
Baud rate - 9600
Clock - 12MHz
SMOD - 1
TH1 - 0xF9
It is given that on reset it is cleared, so by default it is 0. But the red note is a precaution for Maverickmax

Sarang
 

baud rate crystals

Hey guys

Thank you for letting me know. The reason I asked about baud rate with 12MHz is that I am connecting my chip to my radio module which require operate at 9600 baud rate and I get weird message coming out of it. So I suspected 12MHz oscillator crystal was the problem and I was about to use 11.059MHz instead but I needed to check it with you guys. So I was correct.


Maverick Max
 

[at89c51]baud rate setting

goto atmel.com then to 8051 then to c tutorials
 

atmel 8051 baud rate calculator

hi

Ff Baud rates for SMOD=1, then 1/12 of XTAL is divided by 16 and that is frequency used by timer 1 to set baud rate.In case of XTAL=11.0592Mhz, we have

Machine cycle frequency=11.0592Mhz/12=921.6kHz
and
921.6kHz /16=57,600 Hz,since SMOD=1

this is the frequency used by timer 1 to set baud rate.

for example,with XTAL=11.0592,SMOD=1,we have timer 1 frequency=57,600Hz

so 57,600/9600=6
hence,TH1=-6 or TH1=FAH

hope this will help you clear your doubt in writing the pseudo code
 

at89c51 tutorial

goto www.atmel.com u can find a lot of help there and also read 8051 uC and embedded systems by mazidi
 

error 57600 baudrate with 11.0592

hi


i think you need to crosscheck with the datasheet for AT89C51,you can easily get it from site
www.atmel.com

Also i am attaching here a good tutorial on 89C51,might be useful.


regards
john
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top