This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SCI Rx FIFO ISR

Other Parts Discussed in Thread: CONTROLSUITE

Hi Folks

Im struggling a bit setting up the SCIa with FIFO and interrupts. I have a program using the SCI FIFO that uses polling instead of interrupts working, no problem.

However I am attempting to use interrupts now instead and two things are happening that I dont understand: 1) the Tx interrupt fires once as soon as the interrupts are enabled 2) The Rx interrupt never runs (never gets to a break point at the first instruction inside of it)

I am using a very similar setup to the sci feedback loop with interrupts example program except with loop back not enabled, but just cannot understand why the above.

below is my sciaFIFOinit function and my Rx and Tx ints the Tx does nothing for now, I just want to try and read some data in to begin with.

The init function is called from the main() just after the deviceInit and flash init section and the EINT; is the next instruction after that the program is sitting in a while loop doing nothing. The data is sent on the USB by a vb program that has been tested to work with the non-interrupt version of the program.

void sciaFifoInit(void) {
EALLOW; // Map SCI interrupts to ISR functions
PieVectTable.SCIRXINTA = &sciaRxFifoIsr;
PieVectTable.SCITXINTA = &sciaTxFifoIsr;
EDIS;
SciaRegs.SCICCR.all =0x0007; // 1 Stop bit, no loopback
// no parity, 8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // Enable TX, RX, internal SCICLK,
// disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =1; // Enable Tx interrupt
SciaRegs.SCICTL2.bit.RXBKINTENA =1; // Enable RX interrupt
SciaRegs.SCIHBAUD = 0x0000; // SCI BRR = LSPCLK/(SCI BAUDx8) - 1
SciaRegs.SCILBAUD = 0x00C2; // BRR = (15MHz/(Baud x 8)) - 1. 9600 Baud = 194d = C2h.
SciaRegs.SCIFFTX.all = 0xC022; // Hold SCI in reset, enable FIFO, hold FIFO in reset, clear FIFO status, clear int, enable int, set int level to 0
SciaRegs.SCIFFRX.all = 0x0022; // Clear overflow flag, hold FIFO in reset, clear FIFO status, clear int, enable int, set int level to 3
SciaRegs.SCIFFCT.all = 0x00; // Disable auto-baud feature and set Tx delay to 0

SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, INT1
PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2
IER |= M_INT9;
}

interrupt void sciaRxFifoIsr (void) {
// SCI FIFO interrupt (SCIRXINTA) indicating the SCI FIFO has recieved some data
Uint16 rxBuffer[CNTRL_BUF_LEN];
Uint16 i;
for (i=0; i<CNTRL_BUF_LEN; i++) {
rxBuffer[i] = SciaRegs.SCIRXBUF.all; // Read into buffer byte-by-byte
}

sciaTx(0); // Tx response to confirm reciept
SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1; // Clear Overflow flag
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // Clear Interrupt flag
PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Acknowledge CPU interrupt
}

interrupt void sciaTxFifoIsr(void) {
PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Acknowledge CPU interrupt
}
  • Toby,

    You could try using the SCIA Loopback Interrupts example project for F28027, found in controlSUITE, just disable the TX portions.

    Regards,
    Daniel

  • Toby,

    Are you calling EINT; elsewhere in your program?

    The TX INT probably fires because the TX buffer is ready for more data to send.  This seems reasonable to me.  As long as your program services the interrupt properly, this should not cause an issue.  Make sure you clear the SCI interrupt flag in addition to issuing the PIE ACK.  Does your code return to the main() infinite loop after servicing the TX INT?

    What is the value of CNTRL_BUF_LEN?  The code seems to configure the FIFO to generate an RX INT when the FIFO contains 2 words.  You will want to make sure you aren't trying to read more than what is available.

    Regards,
    Daniel

  • Hi Daniel

    Yes I have started with code from that example and basically just disabled the loopback and changed the baud rate. Other than that its pretty similar.

    Yes that makes sense about the Tx interrupt firing

    - EINT is called once after the scia FIFO init function is called.

    - yes after either of the interrupts are called control should return to the main loop. (and does so after the initial Tx interrupt)

    thanks for the check on the CNTRL_BUF_LEN but he program isnt even getting that far, the Rx interrupt is never called, that is my problem, I dont understand why it is not being called when it should be...

    I will add in that SCI interrupt flag clear and try that and let you know how I get on. Thanks.

  • Adding the TXFFINTCLR into the Tx interrupt, and now the Tx interrupt fires constantly over and over again.... probably because the FIFO is still empty and ready... for now I will just leave the flag uncleared. However this means the Rx interrupt is still not occurring...

    :(

  • I finally figured out  what was happening.

    with the FIFO set to 2 levels the Rx int only fires when 2 bytes have been received  and Rx is finished.

    I had been sending more than 2 and thinking the FIFO would read in the first two, fire the interrupt, read in the next two, fire the interrupt, read in the next two, and so on until no more bytes are being received.

    How then i should this work f I wish to send a message longer than the size of the FIFO stack? should I even be using the FIFOs?

    Ta

  • Toby,

    The FIFO RX ISR should trigger when the FIFO level is 2 or greater.  It does not have to be exactly 2.

    Why don't you try the same code using loopback?  To test the RX FIFO, have a TX function that sends more than 2 words at once.  If it works with loopback, perhaps the issue is with how your PC is sending the data to the board.

    Regards,
    Daniel