Wade Smith

Dual SCi on 9S12D64 confused Intr

Discussion created by Wade Smith on Feb 2, 2008
Latest reply on Feb 3, 2008 by Jim Donelson
We are working with a proprietary board based on the Elektronikladen CardS12.D64 using ICC12 and NoICE with the ComPOD12 Pro BDM.  The processor boots up in the TwinPeeks monitor and jumps to the user code at 0x8000 where all of our code starts (including startup and init).

SCI1 is interrupt driven RS485.  SCI0 is polled RS232 half-duplex.

SCI0 set up:
SCI0CR2=TE+RE

SCI1 is outputting a string, so it is set up as:
SCI1CR2=TIE+TE+RE

Initially I did not have any ISR for SCI0, because no interrupts were to be set.  BUT, I found out that I was ALWAYS receiving an interrupt on SCI0.

So now in BOTH ISR functions I check SR1 and respond accordingly.

I set up NoICE and put
asm(" BGND");
in both ISR functions and let NoICE run it.

Of course, when it stops at SCI0ISR, TDRE+TC are set and nothing else.  I check both SCI0SR1 and SCI1SR1 and deal with both (either putChar or getChar for each according to the flags).

Why am I getting SCI0 interrupts when none are set and not getting any SCI1 interrupts?

locations for the TwinPeeks vectors are:

*(int *)0x3FC5 = (int)NETINT;  // SCI1 RS485 interrupt driven
*(int *)0x3FC2 = (int)SCIINT;  // SCI0 Serial RS232 polled
An assembler "JMP" instruction precedes the address so that TwinPeeks will jump to the ISR which ends in the "RTI" instruction.


void SCIINT(void)
{
    INTU8 dummy;

    netSR1 = SCI1SR1;     // read SCI 1 Status Register to clear & analyze it
    sciSR1 = SCI0SR1;     // read SCI 0 Status Register to clear & analyze it
        asm(" bgnd"); /* ### for DEBUG */
        asm(" nop");  /* ### for DEBUG */
        asm(" nop");  /* ### for DEBUG */
    if (sciSR1 & (OR + NF + FE + PF))
    {
        /* Receive ERROR */
        dummy = SCI0DR;   // clear data regi of ?junk?
    }
    else if (sciSR1 & RDRF)
    {
        if (SCI_FLG == SCI_RECEIVE)
        {
            /* do receive */
            //cmdRecv();
            getCharSCI();
        }
        else
        {
            /* clear data register anyway */
            dummy = SCI0DRL;
        } /* end if else */
    }
    if (sciSR1 & (TDRE + TC))
    {
        /* if data availabe for transmission, do transmit */
        if (txBusy)
        {
            //cmdSend();
            putCharSCI();
        } /* end if */
    } /* end if else */


    // check the OTHER serial port for interrupts ALSO
    if (netSR1 & (OR + NF + FE + PF))
    {
        /* Receive ERROR */
    }
    else if (netSR1 & RDRF)
    {
        /* do receive */
        getCharNet();
    }
    else if (netSR1 & (TDRE + TC))
    {
        if (ntxBusy)
        {
            /* do transmit */
            putCharNet();
        } /* end if */
    } /* end if else */


    return;
} /* SCIINT() */

/******************************************************************************/
void NETINT(void)
{
    INTU8 dummy;

    sciSR1 = SCI0SR1;     // read SCI Status Register to clear & analyze it
    netSR1 = SCI1SR1;  // read SCI Status Register to clear & analyze it
        asm(" bgnd"); /* ### for DEBUG */
        asm(" nop");  /* ### for DEBUG */
        asm(" nop");  /* ### for DEBUG */

    if (netSR1 & (RDRF + TDRE + TC))
    {
        if (netDir_FLG == SCI_RECEIVE)
        {
            /* do receive */
            NET_ID();
        }
        else
        {
            /* do transmit */
            NET_SEND();
        } /* end if else */
    } /* end if else */


    // check the OTHER serial port for interrupts ALSO
    if (sciSR1 & (OR + NF + FE + PF))
    {
        /* Receive ERROR */
        dummy = SCI0DRL;   // clear data regi of ?junk?
    }
    else if (sciSR1 & RDRF)
    {
        if (SCI_FLG == SCI_RECEIVE)
        {
            /* do receive */
            getCharSCI();
        } /* end if else */
    } /* end if else */

    if (sciSR1 & (TDRE + TC))
    {
        /* do transmit */
        putCharSCI();
    } /* end if else */

    return;
} /* NETINT() */



If BOTH SCI0 and SCI1 are polled, no problem at all and both ports output strings just fine.  The moment I turn on SCI1CR2 = TIE+TE+RE; disaster strikes and the processor is hung up doing SCI0ISR.  (cuss)

What is going on?  Is there any code I can see that properly handles the dual SCI (polled+interrupt-driven)?

wade

Outcomes