1. 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.
    Dismiss Notice

Serial transmission/ reception using interrrup

Discussion in '8051/8951' started by JeffreyPeter, Mar 9, 2013.

  1. JeffreyPeter

    JeffreyPeter New Member

    Joined:
    Aug 28, 2011
    Messages:
    55
    Likes:
    0
    Hi, This is an serial interrupt code that should not execute while serial transmission but should execute while receiving data. It simulates fine in proteus but on actual hardware implementation, it hangs it is not transmitting data. Please help me debug this code.
    Thanks in advance
    Code (text):
    void serial_receive() interrupt 4
    {
        if(TI==0) // so that it does not execute while transmitting....
        {
            while(RI==0);// non zero character recived
            serial_get=1;
            RI=0;
        }
       
    }
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,164
    Likes:
    910
    Location:
    Rochdale UK
    The only place it can hang is at the " while(RI == 0) " Since The interrupt has already occured, I should leave this out...

    Only include "RI = 0;" at the end of the interrupt...
     
    • Like Like x 1

Share This Page