This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Serial ISR for ADUC842

Hello sir,

I need to write an ISR for serial interrupt.

void serial_int (void) interrupt 4 //ISR for Serial interrupt

{

if((IE & BIT4) == BIT4) //UART interrupt source

REN = 1; // enables serial port reception { while(RI == 0) {} RI = 0; ucRxChar1 = SBUF;
} this is how i have written the ISR...
I am unable to run my program...
it is giving error...
is der any other way to write ISR?

REGARDS
MAYURI

Parents
  • #include<8051.h>
    unsigned char str;
    
    void init_serial()        // Initialize serial port
    {
            TMOD=0x20;        // Mode=2
            TH1=0xfd;         // 9600 baud
            SCON=0x50;        // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit  , Receiving on
            TR1=1;            // Start timer
    }
    
    void transmit_data(unsigned char str)           // Function to transmit data through serial port
    {
            SBUF=str;                               // Store data in sbuf
            while(TI==0);                           // Wait till data transmit
            TI=0;
    }
    
    void receive_data()  interrupt 4         // Function to recieve data serialy from RS232 into microcontroller
     {
             str=SBUF;                       // Read sbuf
             RI=0;
             transmit_data(str);             // Transmit to HyperTerminal
     }
    
    void main()
    {
            init_serial();           // Initialize serial port
            IE=0x90;
            while(1);
    }
    

    Try this to check the interrupt..

Reply
  • #include<8051.h>
    unsigned char str;
    
    void init_serial()        // Initialize serial port
    {
            TMOD=0x20;        // Mode=2
            TH1=0xfd;         // 9600 baud
            SCON=0x50;        // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit  , Receiving on
            TR1=1;            // Start timer
    }
    
    void transmit_data(unsigned char str)           // Function to transmit data through serial port
    {
            SBUF=str;                               // Store data in sbuf
            while(TI==0);                           // Wait till data transmit
            TI=0;
    }
    
    void receive_data()  interrupt 4         // Function to recieve data serialy from RS232 into microcontroller
     {
             str=SBUF;                       // Read sbuf
             RI=0;
             transmit_data(str);             // Transmit to HyperTerminal
     }
    
    void main()
    {
            init_serial();           // Initialize serial port
            IE=0x90;
            while(1);
    }
    

    Try this to check the interrupt..

Children