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.

CCS/TMS320F28377S: SCI FIFO PROBLEM

Part Number: TMS320F28377S


Tool/software: Code Composer Studio

Hi,

I implement the modbus protocol and I have a problem with interrupting RX with fifo.

In my application, incoming frames are of different lengths(once the frame has a length of 12 bytes and the second time is 8 bytes). I received frame in interrupt.
When I set RXFFIL = 7 and the frame comes in length 13, error flags such as PE and FE appear.

To sum up how to set an interrupt so that can receive frames of a different length (the frame will be as long as the size FIFO allows) without errors ?

Thank you for helping
Best regards
Szymon
  • Hi Szy,

    See e2e.ti.com/.../496489

    It kinda depends on the application and how quickly you need to respond to the messages. You could maybe process the received messages in the background loop, pulling off whatever you see in the RX FIFO to some other memory. As you do this you could check to see if the message is complete. To prevent FIFO overflow you could trigger an ISR when the RX FIFO is full to immediately copy all the bytes to the memory where you are assembling the messages.
  • Hi Devin,

    Thank you for your answer.

    According to your suggestion, I set the fifo level to 8 and when the 8-byte frame comes, everything works perfectly.
    But when a 12 byte frame comes, I read only 8 bytes and 5 get lost. What to do not to lose part of the frame ?
    I can not call an ISR when the RX FIFO is full because then I will get the entire first frame (8 bytes) and part of the next frame (8 bytes from the 13 byte frame) which is unacceptable in my application.

    Best regards
    Szymon
  • Hi,

    I  adds my settings

    interrupt void scicRxFifoIsr(void)
    {
        Uint32 i = 0;
        while(ScicRegs.SCIFFRX.bit.RXFFST != 0){
            RxMODBUS[i]=ScicRegs.SCIRXBUF.all;
            i++;// Read data}
        }
    
        GpioDataRegs.GPASET.bit.GPIO19 = 1;
    
        ScicRegs.SCIFFRX.bit.RXFFOVRCLR=1;   // Clear Overflow flag
        ScicRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
    
        PieCtrlRegs.PIEACK.all|=0x80;       // Issue PIE ack
    }
    
    void scia_fifo_init()
    {
       ScicRegs.SCICCR.all = 0x0067;      // 1 stop bit,  No loopback
                                          // No parity,8 char bits,
                                          // async mode, idle-line protocol
       ScicRegs.SCICTL1.all = 0x0003;     // enable TX, RX, internal SCICLK,
                                          // Disable RX ERR, SLEEP, TXWAKE
       ScicRegs.SCICTL2.bit.TXINTENA = 0;
       ScicRegs.SCICTL2.bit.RXBKINTENA = 1;
       ScicRegs.SCIHBAUD.all = 0x0000;
       ScicRegs.SCILBAUD.all = 0x00A2;
       ScicRegs.SCICCR.bit.LOOPBKENA = 0; // Enable loop back
       ScicRegs.SCIFFTX.all = 0xC021;
       ScicRegs.SCIFFRX.all = 0x0028;
       ScicRegs.SCIFFCT.all = 0x00;
    
       ScicRegs.SCICTL1.all = 0x0023;     // Relinquish SCI from Reset
       ScicRegs.SCIFFTX.bit.TXFIFORESET = 1;
       ScicRegs.SCIFFRX.bit.RXFIFORESET = 1;
    }
    

  • Hi Szymon,

    Regardless of the FIFO size, you aren't going to be able to use a specific ISR to indicate the end of a message since the message size is variable. Presumably there is some information in the message that also indicates the size? In that case you can continuously draw down any bytes in the RX FIFO (in a background loop or in a periodic ISR) to some intermediate memory. You would then check if the message is complete each time you draw a byte off of the FIFO. You might enable an ISR when the RX FIFO is full to prevent overrun if the background loop is too slow.

    If there isn't any information in the message about how long the message is, then you probably need to receive each byte 1-by-1. When you get the first byte, start an ePWM or CPU timer to detect timeout (end of the message). Each time you get a new byte restart the timeout timer.
  • Hi,

    Thank you for your help. 
    I have one more question.

    Do you have an example code for implementing what you are writing about?

    Best regards

    Szymon

  • Hi Szymon,

    Unfortunately we don't have an example of this.