Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

8051 serial port interrupt for half duplex operation

Status
Not open for further replies.

mesamune80

New Member
Hi, everyone i wonder how am i going to do a multiprocessor half duplex.operation with 8051 using C to write it.i want to send 5 bytes to another micro(B) then it will send back to me 5 bytes,to indicate that it received the previous 5 bytes from the 1st micro,i need a switch for the micro(A) to start transmit the 5 bytes,and when miro(A) received the 5 bytes that send by micro(B) then a LED will flash ON.Anybody has any idea how to accomplish this task?Thanks for your help i really appriciate it.
and i need to check whether the bytes send are correct or not let say i want 1,2,3,4,5
i have to ensure that 1,2,3,4,5 are transmitted.
 
Just use the UART. Its a full duplex serial interface using 2 wires. Just connect the TX on one controller to RX on the other. You might have to invert the bytes you recieve
 
Code:
__bit RecievedFlag = 0;
__bit BusyFlag = 0;
unsigned char SerialData;

while(1)
{
   if (RI) 
   {
       RI = 0;
       SerialData = SBUF;
       RecievedFlag = 1;
   }
   if (RecievedFlag & (!BusyFlag))
   {
       SBUF = SerialData;
       BusyFlag = 1;
    }
   if (TI)
   {
       TI = 0;
       BusyFlag = 0;
      ReceivedFlag = 0;
   }
}

I heven't tested this code - i don't have any code on hand that just reads the UART so I just slapped this together. This code gives the general idea for reading and writing the UART. The code as is should echo characters received from the UART.
 
Status
Not open for further replies.

Latest threads

Back
Top