My program uses the serial port but doesn't seem to send any data. Why?
Submitted By: Craig Steiner FAQ Last Modified: 07/10/06
- If you are using the 8052 serial port and sending data by writing it to the SBUF SFR (MOV SBUF,#41h, etc.) but don't seem to be seeing the data, check the following:
- Are you sure you configured the serial port and timer correctly to achieve the desired baud rate? Do the calculations in #1 (above) again to make sure you got it right.
- Is the receiving program (i.e., your PC or other device) set to the same baud rate? Double check. You might also want to try setting your PC to other common baud rates (300, 1200, 2400, etc.) just to see if, by chance, you accidentally configured the 8052 to another baud rate. If you find that you find everything working when you set your PC to 2400 baud, you *know* that you messed up the baud rate calculation. See question #1 to correct your baud rate.
- If you are using the technique in #3 (above) where you first wait for the TI bit to be set before clearing it and sending the next byte, are you sure that you initialized TI to 1 when you first configured the serial port? Using the technique in #3 requires that the TI first be initialized to 1, otherwise your code will loop indefinitely at the JNB instruction.
- Are you sure you're using the right type of cable? Verify whether your configuration requires a standard RS232 cable or a null-modem cable which has TX and RX swapped.
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.