We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I am trying to implement serial communication from my real time hardware system. I have developed my source code KEIL and verified using serial software simulator of KEIL. I am getting perfect result. But when I am trying to implement on the real time hardware system I am unable to get the desired result. I am using the real time hardware system with a baud rate of 2400bps. Can anyone please explain what could be the possible reason.
regards. raghun
try speeding up things, comp has baud of 9600, setting both to same should do something,
so many New threads and no response to Some queries in the older threads,
HI neil, Thanks for the reply. I am actually using a 24MHz crystal. So if I use buad rate of 9600 the calculated bps for 8051 would end up some where around 10500. so there is error margin of atleast 1000 bps. that is the reason why I have to stick for lesser buad rates of 2400 & 1200. for 2400 buad rate i get error margin of 3bps and for 1200 buad rate i get error margin of 1 bps
regards raghun
"try speeding up things, comp has baud of 9600, setting both to same should do something,"
No, I didn't write that!
If you look at any of my previous posts, you'll see that it's not the way that I write!
"comp has baud of 9600"
This is, of course, rubbish!
What is "comp"? How does (s)he know that is has a baud [rate] of 9600?!
"setting both to same should do something"
Yes, of course, both ends of the link must be using the same parameters - number of data bits, number of stop bits, parity and speed (baud rate).
Have you checked that your target hardware is actually generating an accurate 2400 baud? It needs to be within a percent or so...
"I am actually using a 24MHz crystal. So if I use buad rate of 9600 the calculated bps for 8051 would end up some where around 10500."
Eh???
Then you're doing the calculation wrong!
There is no reason why you can't get 9600 baud from a 24MHz crystal!
See: http://www.keil.com/c51/baudrate.asp
GO to the horse's mouth;
dishonest, pirates, illegal version, playful, wat not,
A Quartz with 22.118400 MHz is standart available at most Electronic vendors. So just use it and be happy with exact Baud-rates.
Sincely yours
If 22.118400 MHz is really out of the question, I've had no problems with 9600 baud when using a 24MHz Crystal...
Hello Andy or whoever you are!!!!
You can not make exact 9600 Baud with a 24MHz crystal, the Baudrate wouldn't be exact. The architekture of 8051-UART don't allow this.
If you believe, that you have managed this task, then your wellcome to post your code.
"You can not make exact 9600 Baud with a 24MHz crystal, the Baudrate wouldn't be exact."
Not exact, but close enough (+0.16% error).
PCON |= 0x80; // Set double-rate bit, SMOD TMOD &= 0x0F; // Clear Timer 1 control bits, upper nibble, in TMOD register TMOD |= 0x20; // Put Timer 1 in 8-bit, auto-reload mode (Timer 1, Mode 2) TH1 = 0xf3; // Define Timer 1 reload value RCLK = 0; // Define Timer 1 as the UART receiver baud clock (T2CON.5) TCLK = 0; // Define Timer 1 as the UART transmitter baud clock (T2CON.4) TR1 = 1; // Enable Timer 1 as baud-rate generator (TCON.6)
Check it out at: http://www.keil.com/c51/baudrate.asp