I'm trying to receive data with the serial port but never receive anything. Why?
Submitted By: Craig Steiner FAQ Last Modified: 07/10/06
- If you are using the 8052 serial port to receive data but the data that is being sent to the 8052 doesn't seem to be received by your program, try the following ideas:
- Review the options in #5 and try to *SEND* data from the 8052 to your PC or other test device. If you can successfully send data back to the PC, you've eliminated quite a few possibilities. If you can't send data to the PC, try to get that working before you worry about receiving. Very possibly, once you can send data to the PC you'll also be able to receive data. It's generally easier to debug serial send problems than serial receive problems.
- When you configured the serial port, did you remember to set the REN (SCON.4)? This bit must be enabled to receive data via the serial port and is normally set when you first configure the serial port by initializing SCON.
- Are you waiting to read the SBUF SFR until RI goes high? The 8052 will automatically set RI when a character is received. At that time, you may read SBUF and clear RI.
Add Information to this FAQ: If you have additional information or alternative solutions to this question, you may add to this FAQ by clicking here.