Dual SCi on 9S12D64 confused Intr

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dual SCi on 9S12D64 confused Intr

2,726 Views
warm38spl
Contributor I
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

Labels (1)
0 Kudos
Reply
5 Replies

1,369 Views
JimDon
Senior Contributor III
On the surface you code looks ok.

I am not too familiar with Twin Peeks, but double check and make sure you have not reversed the vector locations. That's what it sound like to me, that you pointed the SCI0 vector to the SCI1 handler and visa versa.


0 Kudos
Reply

1,369 Views
warm38spl
Contributor I
#1  they are in the correct order according to the Freescale PDF files I have.
#2  notice that in all cases, I read SCI0SR1 and SCI1SR1, which means that the Interrupt Flag should be cleared no matter which ISR fires off.  And yet, I get continuous interrupts as though I never read any SCIxSR1. 

If I poll BOTH SCI ports for input/output,  there is no problem at all.  This indicates: #1 the lines are correctly connected and #2 the ports are properly configured.

Changing to one port interrupt driven (SCI1) everything goes nuts.

I suppose I could convert both ports to interrupt driven, but I'm not too sure about doing the interactive user interface via interrupts (SCI0) -- no problem with talking to the RS485 on SCI1 via interrupts, but people.....


0 Kudos
Reply

1,369 Views
JimDon
Senior Contributor III
The order has to do with what twinpeeks decides to do, if I understand correctly, not the Freescale docs.
Get rid of twinpeeks, then you should be able to use the tons of sample code available.
Also, as no one else here uses it, you will get much better help.

You will of course find that some how the vectors are mixed up or there is some other part of the code that is wrong.

If you only enable the interrupt on one port, you will for sure not get it on the other.
Also clearing the interrupt flag will stop the interrupt. Trust me, there is some think else going on.

Here is sample code. Scroll down the page find it, and examine it.

I recommend you down load and try this sample code anyway, because it works for  sure.
At this point, there should be no need to explain any of this and further, as this sample code tells it all.
Of course you can use one port interrupt driven and the other not. In fact, I usually do Rx interrupt driven and Tx not.


0 Kudos
Reply

1,369 Views
warm38spl
Contributor I
You were right!

That IS the problem! Originally SCI0 was the RS485 and SCI1 was the RS232. I swapped them in the RAM table because the EEs has swapped the usage of the SCI ports. Everything else in the table goes in ascending address except SCI0 and SCI1.  I forgot to swap them when their functions became "normal".

D'OH!   1 week lost.

wade



0 Kudos
Reply

1,369 Views
JimDon
Senior Contributor III
Thanks for getting back and telling me.

From you description, it had to be that.
It's easy to bask in the warm glow of being right, difficult to admit a mistake.
From time to time it happens to us all.

0 Kudos
Reply