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 ISRs

I have a simple program which is only responding to my serial isr. I am using TI's MSC1210Y5 which has two UARTs on board, Port 0 and Port 1. I want to turn on a led when I receive a character on Port 1.

The serial interface is set up as follows:

//      Set Serial Port 0
        SCON0 = 0x50;
        PCON |= 0x80;   //Set Baud Rate doubler for Serial Port 0

//      Set Serial Port 1
        SCON1 = 0x50;
        EICON |= 0x80;  //Set Baud Rate doubler for Serial Port 1


//      Set timer 1 up as a baud rate generator.
        TR1 = 0;            /* stop timer 1 */
        ET1 = 0;            /* disable timer 1 interrupt */

        TMOD &= ~0xF0;      /* clear timer 1 mode bits */
        TMOD |= 0x20;       /* put timer 1 into MODE 2 */

        TH1 = (unsigned char) (256 - (XTAL / (16L * 12L * baudrate)));

        TR1 = 1;            /* start timer 1 */

//      Clear Serial Rx Flag
        RI_0 = 0;
        RI_1 = 0;

//      Clear tx flag
        TI_0 = 1;
        TI_1 = 0;

//      Set serial intterrups
        ES0 = 1;                                        //Enable Serial Port 0 Interrupt
        ES1 = 1;                                        //Enable Serial Port 1 Interrupt
        PS  = 1;                                        //Serial Interrupt Priority HIGH

My isr looks like this:

static void Serial_isr(void) interrupt 4
{

//      Port 0 rx
        if ( RI_0 )
                RI_0 = 0;

//      Port 1 rx
        if ( RI_1 )
        {
                RI_1 = 0;
                led_sys_err_1 = ON;

        } //__if ( RI_1 )__

}

The problem is that my isr is only triggered when I set

TI_0 = 1

I know you have to set TI_0 = 1 for printf() to work, but why should my Rx on Port 1 depend on my Tx on Port 0?

Thanks.

0