??? 06/07/11 09:24 Read: times |
#182514 - Help on Serial Port |
Dear all,
I have come across another problem, and it seems I'm running out of ideas on where the problem lies. I am using AT89S51. My project is to received a stream of data via RS485 and select the specified data as the station number of each uC. Now, I'm just testing the serial port ... And I keep on finding as is my serial port does not work as I wanted ... As I keep on trying to sort out all possibilities. I'm using this code bellow. The idea of this code is the uC keeps on sending the Acc that was read from P1 and outputs the value to P2. And if I short the Tx and Rx port of the uC, then I should received the same data that I was sending out. To prove that I have received the data, I swaped the Acc and output it to P2. The P0.0 is for giving pulse to P0.0 (MAX1232) as my reset generator. Here is my code : $MOD51 org 0000H ljmp INITIAL org 0100H INITIAL: setb P0.0 mov TH1,#0FDH mov TMOD,#20H setb TR1 clr P0.0 mov PCON,#00H mov SCON,#0D0H clr TI clr RI MULAI: setb P0.0 mov A,P1 mov P2,A mov SBUF,A clr P0.0 clr TI jb RI,SERIAL_RECEIVED ljmp MULAI org 0150H SERIAL_RECEIVED: clr P0.0 mov A,SBUF swap A setb P0.0 mov P2,A jmp SERIAL_RECEIVED And ... I'm stuck ... My code keeps on running as if it does not reads the Rx even I have short the Tx and Rx port ... Any idea ??? Please ... |
Topic | Author | Date |
Help on Serial Port | 01/01/70 00:00 | |
Try polling the TI flag before writing to SBUF.. | 01/01/70 00:00 | |
What is polling ? | 01/01/70 00:00 | |
Re: what is polling.. | 01/01/70 00:00 | |
Re: what is polling | 01/01/70 00:00 | |
Polling ... | 01/01/70 00:00 | |
While I don't normally mind.. | 01/01/70 00:00 | |
Detailed answers | 01/01/70 00:00 | |
if you want help ... | 01/01/70 00:00 | |
How to post legible source code | 01/01/70 00:00 | |
Posting source code | 01/01/70 00:00 | |
Re: if you want help ... | 01/01/70 00:00 | |
some errors | 01/01/70 00:00 | |
Re: some errors | 01/01/70 00:00 | |
Is it working if | 01/01/70 00:00 | |
Worked !!! | 01/01/70 00:00 | |
dont forget RI | 01/01/70 00:00 |