Sir, I am having trouble in saving the data received from the rxd of 89c52. when i debug the program and i checked the values and changed the SBUF value and on further checking the values of the temp=SBUF the temp value is still on 0.
unsigned char temp; void serial_read() // read byte { while(RI==0); temp=SBUF; RI=0; }
and there is a doubt that if we return the SBUF value this is not working.
unsigned char serial_read() { while(RI==0); return SBUF; }
Thanks in advance.
I think this post got off on the wrong foot and Per and Erik muddied the waters. What they both posted is true. Both the xmit and the receive SBUF exist at the same SFR address. You can't write to the receive SBUF and you can't read the xmit SBUF.
But the SBUF is very seldom the problem in USART communication. Forget that approach. When you write to the xmit SBUF the data goes out period if you have the clocks enabled, etc.
So the first thing to do is to connect to a terminal such as Hyperterminal and look for data. If you get garbage data or no data you have a place to start debugging. Do you have a scope or logic probe of some type. Take a look a the data lines. Are you getting any signal transmission? Are you getting garbage data out? If so, you probably have a problem with baud rate settings.
The same approach with receive data. Are you getting data on the receive RX pin? Have your buddy punch the 'U' key over and over while you look for signals on the RX pin.
Are you receiving data on the RX pin? Are you using some type of eval board or a target board that you have fabricated? If you are using an eval board have you checked to see if there are jumpers or switches to set?
We could go on and on with this but you need to put a little more effort in asking more direct questions. Not questions like why can't I read the SBUF? Tell us what you have tested and verified.
The Keil examples have a number of good examples for serial UART communications. Have you tried any of the these examples?
From the simulator/debugger you can redirect serial communications out the PC serial port if you have a serial port on you PC. Half my PC no longer have serial ports.
What all this verbage is saying is move on past the SBUF. The chip hardware works. You don't need to trouble shoot the chip. You need to trouble shoot the target board and your software.
Bradford
Per got to the point while I w2as still typing.
:)
Easy to get side stepped there instead of trying to look for progress.
Bradford Thank you sir, that helped me a lot. Actually we are testing it directly with a RF module (315/434 MHz transmitter and receiver) on two separate circuits. And using 89c52 serial communication ports to send data through transmitter (in P3^1) and receive data via receiver (in P3^0). I think the problem is with the baud rates since this module is capable for 300 baudrate operation. And i am using 9600 baudrate.
I think the problem is with the baud rates since this module is capable for 300 baudrate operation. And i am using 9600 baudrate.
you should not dont think so, you should know so
is 300bps REALLY all the module can handle
why do you think a module only capable of 300 bps will get any information out of data sent at 9600?
Erik