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.

F28377D SCI FIFO Interrupt problem

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I'm using F28377D to demo the controlSUITE code, 2837xDSci_FFDLB.

And there is a question bother me, it's about the transmit FIFO interrupt implementation.

As i read the SCI technical doc, the description of TXFFIL bits is

TXFFIL4–0 Transmit FIFO interrupt level bits. Transmit FIFO will generate interrupt when the FIFO status bits (TXFFST4–0) and FIFO level bits (TXFFIL4–0 ) match (less than or equal to).

 In my opinion, if FFST less than or equal to FFIL, it will execute the tx interrupt to do something(sending data in example code).

 if i set TXFFIL = 0x2, and i don't have any data require to send.

In this case, TXFFST will be zero no doubt, but it will cause the TX Interrupt fired.(TXFFST = 0 less than TXFFIL = 2)

This means even if i don't have any data to send, it will execute interrupt continuously.

Does there have any method to avoid this situation? 

Thanks!

 

  • This post has been Edited on 02-02-2017

    ****************************************Original Post****************************************

    Shuen,

    I see your confusion. The check is "TXFFIL<=TXFFST". It DOES NOT DO the following" TXFFST<=TXFFIL". To put this into words, the interrupt is fired when TXFFST is larger than or equal to TXFFIL.

    Regards,
    Cody

    ****************************************End Original Post****************************************

    The above information in this post is incorrect, the corrected information can be found in a post below by Cody Watkins on Jan 26, 2017 at 5:38 PM.

    Regards,
    Cody

  • Thanks for your reply

    As your explained, it should be fired when TXFFST >= TXFFIL on this condition.

    I command the sending data code in sciaTxFifoIsr, and add a counter in it so that check out if the tx interrupt be fired or not.

    TXFFIL be set by 2, in this case, TXFFST will be zero( No data transmit ), and it is NOT able to execute TX interrupt. ( TXFFIL>= TXFFST )

    However, my counter is still counting at this time.

    my code is attached below.

    void main(void)
    {
       Uint16 i;
    
    //
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    //
       InitSysCtrl();
    
    //
    // Step 2. Initialize GPIO:
    // This example function is found in the F2837xD_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    //
       InitGpio();
    
    //
    // For this example, only init the pins for the SCI-A port.
    //  GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
    //  GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
    // These functions are found in the F2837xD_Gpio.c file.
    //
       GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
       GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);
    
    //
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
    //
       DINT;
    //
    // Initialize PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the F2837xD_PieCtrl.c file.
    //
       InitPieCtrl();
    
    //
    // Disable CPU interrupts and clear all CPU interrupt flags:
    //
       IER = 0x0000;
       IFR = 0x0000;
    
    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F2837xD_DefaultIsr.c.
    // This function is found in F2837xD_PieVect.c.
    //
       InitPieVectTable();
    
    //
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
    //
       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.SCIA_RX_INT = &sciaRxFifoIsr;
       PieVectTable.SCIA_TX_INT = &sciaTxFifoIsr;
       EDIS;    // This is needed to disable write to EALLOW protected registers
    
       //GPIO TOGGLE SETTING
       EALLOW;
       GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0;
       GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
       EDIS;
    //
    // Step 4. Initialize the Device Peripherals:
    //
       scia_fifo_init();  // Init SCI-A
    
    //
    // Step 5. User specific code, enable interrupts:
    //
    // Init send data.  After each transmission this data
    // will be updated for the next transmission
    //
    
    /*   for(i = 0; i<2; i++)
       {
          sdataA[i] = i;
       }
    
       rdata_pointA = sdataA[0];
    */
    
    //
    // Enable interrupts required for this example
    //
       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 = 0x100;                         // Enable CPU INT
       EINT;
    
    
    //
    // Step 6. IDLE loop. Just sit and loop forever (optional):
    //
        for(;;);
    }
    
    
    
    interrupt void sciaTxFifoIsr(void)
    {
        count++;
    
    /*
        for(i=0; i< 2; i++)
        {
           SciaRegs.SCITXBUF.all=sdataA[i];  // Send data
        }
    */
    /*
        for(i=0; i< 2; i++)                  // Increment send data for next cycle
        {
           sdataA[i] = (sdataA[i]+1) & 0x00FF;
        }
    */
        SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;   // Clear SCI Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ACK
    }
    
    interrupt void sciaRxFifoIsr(void)
    {
    
    /*    for(i=0;i<2;i++)
        {
           rdataA[i]=SciaRegs.SCIRXBUF.all;  // Read data
        }
    */
    /*    for(i=0;i<2;i++)                     // Check received data
        {
           if(rdataA[i] != ( (rdata_pointA+i) & 0x00FF) )
           {
               error();
           }
        }
    
        rdata_pointA = (rdata_pointA+1) & 0x00FF;
    */
        SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;   // Clear Overflow flag
        SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
    
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
    }
    
    void scia_fifo_init()
    {
       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;
       //SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
       SciaRegs.SCIHBAUD.all = 0x00;
       SciaRegs.SCILBAUD.all = 0x6b;
    //   SciaRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop back
       SciaRegs.SCIFFTX.all = 0xC022;
       SciaRegs.SCIFFRX.all = 0x0028;
       SciaRegs.SCIFFCT.all = 0x00;
    
       SciaRegs.SCICTL1.all = 0x0023;     // Relinquish SCI from Reset
       SciaRegs.SCIFFTX.bit.TXFIFORESET = 1;
       SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
    }

    It doesn't make sense if tx interrupt be fired when TXFFST greater than or equal to TXFFIL.

    The counter shouldn't be count on this condition.

  • Shuen,

    I would like to apologize I incorrectly described the TXFFIL register to you. What I described to you was how the RXFFIL register works.

    To clarify:

    TXFFIL: an interrupt occurs during the following condition TXFFIL<= TXFFST. You receive this interrupt when the SCI is running out of messages to send. At this time the CPU needs to provide more messages to the SCI module.

    RXFFIL:an interrupt occurs during the following condition RXFFIL>= RXFFST. You receive this interrupt when the SCI RX FIFO is running out of room. At this time the CPU needs to read the received messages from the SCI module.

    During periods of long time where you don't send data you can disable the interrupts. Or if your SCI is not very active it may make more sense to not use the FIFO enhancements.

    Regards,
    Cody

  • Hi Cody
    It's a good news for me that i'm not misunderstanding the definition of TXFFIL.
    And then i try your suggestion about enable and disable interrupt.
    It works perfectly!
    Anyway, Thanks for your help!
  • Shuen,
    I'm glad to hear your solution is working! If you have anymore issues feel free to start a new post.

    Regards,
    Cody