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-B FIFO interrupt not working

Other Parts Discussed in Thread: TMS320F2812

Hello,

I am using SCI-B interface on my TMS320F2812. I am using FIFO enhancements and just receiving one character for the time being. So i have written the the program to generate an interrupt when a single character is received.

But the the problem is that the interrupt is not running for some reason and i cannot find out why. Can someone please help me.

Here is my code-

#include "DSP281x_Device.h"   
#include "DSP281x_Examples.h"
#include <stdio.h>


interrupt void scibRxFifoIsr(void);
void InitSystem(void);
void Gpio_select(void);
void InitPieCtrl(void);
interrupt void scibRxFifoIsr(void);  
void scib_fifo_init(void);
void Delay_1ms(long);  
 

unsigned char rdataB;    // Received data for SCI-B

void main(void)   
    {    
        
       
    // Initialize System Control:  
       InitSystem();   
       
    // Initalize GPIO:    
       Gpio_select();     
       
    //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.     
       InitPieCtrl();

   // Disable CPU interrupts and clear all CPU interrupt flags:   
       IER = 0x0000;   
       IFR = 0x0000;  

   // Interrupts that are used in this example are re-mapped to   
    // ISR functions found within this file.     
       EALLOW;  
       PieVectTable.RXBINT = &scibRxFifoIsr;      
       EDIS;  

    //Initialize all the Device Peripherals:
      scib_fifo_init();  // Init SCI-B
      
       
    // Enable interrupts required for this example   
     PieCtrlRegs.PIEIER9.bit.INTx3=1;  // PIE Group 9, INT3
     IER = 0x100; // Enable CPU INT
     EINT;            

    // IDLE loop. Just sit and loop forever (optional):    
        for(;;);   
       
    }    

void InitSystem(void)
{
       EALLOW;
       SysCtrlRegs.WDCR= 0x0068;        // Setup the watchdog
                                       // 0x00E8  to disable the Watchdog , Prescaler = 1
                                       // 0x00AF  to NOT disable the Watchdog, Prescaler = 64
       SysCtrlRegs.SCSR = 0;             // Watchdog generates a RESET    
       SysCtrlRegs.PLLCR.bit.DIV = 10;    // Setup the Clock PLL to multiply by 5
    
       SysCtrlRegs.HISPCP.all = 0x1; // Setup Highspeed Clock Prescaler to divide by 2
       SysCtrlRegs.LOSPCP.all = 0x2; // Setup Lowspeed CLock Prescaler to divide by 4
          
       // Peripheral clock enables set for the selected peripherals.   
       SysCtrlRegs.PCLKCR.bit.EVAENCLK=0;
       SysCtrlRegs.PCLKCR.bit.EVBENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SCIAENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SCIBENCLK=1;
       SysCtrlRegs.PCLKCR.bit.MCBSPENCLK=0;
       SysCtrlRegs.PCLKCR.bit.SPIENCLK=0;
       SysCtrlRegs.PCLKCR.bit.ECANENCLK=0;
       SysCtrlRegs.PCLKCR.bit.ADCENCLK=0;
       EDIS;
}

void Gpio_select(void)
{
    EALLOW;
    GpioMuxRegs.GPAMUX.all = 0x0;    // all GPIO port Pin's to I/O
    GpioMuxRegs.GPBMUX.all = 0x0;   
    GpioMuxRegs.GPDMUX.all = 0x0;
    GpioMuxRegs.GPFMUX.all = 0x0;        
    GpioMuxRegs.GPEMUX.all = 0x0;
    GpioMuxRegs.GPGMUX.all = 0x0;
    GpioMuxRegs.GPGMUX.bit.SCIRXDB_GPIOG5 = 1; //SCI-RX
    GpioMuxRegs.GPGMUX.bit.SCITXDB_GPIOG4 = 1; //SCI-TX            
                                        
    GpioMuxRegs.GPADIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPBDIR.all = 0x00FF;    // GPIO Port B15-B8 input , B7-B0 output
    GpioMuxRegs.GPDDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPEDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPFDIR.all = 0x0;    // GPIO PORT  as input
    GpioMuxRegs.GPGDIR.all = 0x0;    // GPIO PORT  as input

    GpioMuxRegs.GPAQUAL.all = 0x0;    // Set GPIO input qualifier values to zero
    GpioMuxRegs.GPBQUAL.all = 0x0;
    GpioMuxRegs.GPDQUAL.all = 0x0;
    GpioMuxRegs.GPEQUAL.all = 0x0;
    EDIS;
}  
void InitPieCtrl(void)   
{   
    // Disable Interrupts at the CPU level:   
    DINT;   
   
    // Disable the PIE   
    PieCtrlRegs.PIECRTL.bit.ENPIE = 0;   
   
    // Clear all PIEIER registers:   
    PieCtrlRegs.PIEIER1.all = 0;   
    PieCtrlRegs.PIEIER2.all = 0;   
    PieCtrlRegs.PIEIER3.all = 0;       
    PieCtrlRegs.PIEIER4.all = 0;   
    PieCtrlRegs.PIEIER5.all = 0;   
    PieCtrlRegs.PIEIER6.all = 0;   
    PieCtrlRegs.PIEIER7.all = 0;   
    PieCtrlRegs.PIEIER8.all = 0;   
    PieCtrlRegs.PIEIER9.all = 0;   
    PieCtrlRegs.PIEIER10.all = 0;   
    PieCtrlRegs.PIEIER11.all = 0;   
    PieCtrlRegs.PIEIER12.all = 0;   
   
    // Clear all PIEIFR registers:   
    PieCtrlRegs.PIEIFR1.all = 0;   
    PieCtrlRegs.PIEIFR2.all = 0;   
    PieCtrlRegs.PIEIFR3.all = 0;       
    PieCtrlRegs.PIEIFR4.all = 0;   
    PieCtrlRegs.PIEIFR5.all = 0;   
    PieCtrlRegs.PIEIFR6.all = 0;   
    PieCtrlRegs.PIEIFR7.all = 0;   
    PieCtrlRegs.PIEIFR8.all = 0;   
    PieCtrlRegs.PIEIFR9.all = 0;   
    PieCtrlRegs.PIEIFR10.all = 0;   
    PieCtrlRegs.PIEIFR11.all = 0;   
    PieCtrlRegs.PIEIFR12.all = 0;   
   
   
}   

 void scib_fifo_init()                                          
    {   
       ScibRegs.SCICCR.all =0x0007;    // 1 stop bit,  No loopback    
                                       // No parity,8 char bits,   
                                       // async mode, idle-line protocol   
       ScibRegs.SCICTL1.all =0x0003;   // enable TX, RX, internal SCICLK,    
                                       // Disable RX ERR, SLEEP, TXWAKE      
       ScibRegs.SCICTL2.bit.RXBKINTENA =1;   
       ScibRegs.SCIHBAUD    =0x01;   
       ScibRegs.SCILBAUD    =0xE7;   
       ScibRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back       
       ScibRegs.SCIFFRX.all=0x0021;   
       ScibRegs.SCIFFCT.all=0x00;   
       
       ScibRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset    
       ScibRegs.SCIFFRX.bit.RXFIFORESET=1;      
             
    }   

interrupt void scibRxFifoIsr(void)   
    {   
         
        rdataB=ScibRegs.SCIRXBUF.all;  // Read data   
    
        if(rdataB=='a')
            {
        
                 GpioDataRegs.GPBDAT.all = 0x00;
                Delay_1ms(1000);
                                  
            }
                                      
        ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1;  // Clear Overflow flag   
        ScibRegs.SCIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag   
        PieCtrlRegs.PIEACK.all=0x100;      // Issue PIE ack   
}

void Delay_1ms(long end)
{
    long i;
    for (i = 0; i <(9000 * end); i++);
}

Thanks in advance.

  • Hello,

    First of all, it should be  InitPieVectTable(); before this line:

    Rachit Jain said:
       // Interrupts that are used in this example are re-mapped to   
        // ISR functions found within this file.     
           EALLOW;  
           PieVectTable.RXBINT = &scibRxFifoIsr;      
           EDIS;  

    Like the example below from  C:\tidcs\c28\DSP281x\v120\DSP281x_examples\sci_loopback_interrupts

    // 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 DSP281x_DefaultIsr.c.
    // This function is found in DSP281x_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.RXAINT = &sciaRxFifoIsr;
       PieVectTable.TXAINT = &sciaTxFifoIsr;
       PieVectTable.RXBINT = &scibRxFifoIsr;

    ...

    Please refer again this example to generate the interrupt and if it is still doesn't work, please let us know.

    Best regards,

    Maria

  • I have added both the DSP281x_DefaultIsr.c and the  DSP281x_PieVect.c as it is. Also added the function  in between as you told ,but still there is no interrupt response.

     

    I'm trying to receive a "a" via the HyperTerminal and thus switch the GPIO pins low. Using SCI-B for that.

    Since there is only one character thus i have written the code as-

    ScibRegs.SCIFFRX.all=0x0021;

    and then i have set-

    ScibRegs.SCIFFRX.bit.RXFIFORESET=1;

    and i have enabled all the other signals-

     PieCtrlRegs.PIEIER9.bit.INTx3=1;

    IER = 0x100;

    thus the interrupt should flow smoothly and the B port should be set low. But this is not happening.

    Can you please help me out.

    Thank you

  • Hello,

    Please define SCIFFTX too, there is bit that used to enable the FIFO and also bit to reset the SCI.

    Best regards,

    Maria

  • Rachit,

    If you read the port by polling, do you get the characters?

    I found that I had to detect error conditions in my receive interrupt, as I would occasionally get a BREAK condition, and the only way to recover was to reset the UART.  Code:

    if (ScibRegs.SCIRXST.bit.RXERROR) {
    // Must reset device. First wait for XMIT to finish.
    while (ScibRegs.SCICTL2.bit.TXRDY == 0) ;

    // Now toggle software reset. This does not affect the configuration.
    ScibRegs.SCICTL1.bit.SWRESET = 0;
    ScibRegs.SCICTL1.bit.SWRESET = 1;
    }

  • Maria,


    I am just trying to receive the  data. I am not exactly using the example code.

    The thing i want to do is receive a character at the receiver of the SCI-B and generate an interrupt that will ground the B port pins(B0 to B7).

    Is it necessary to initialize the SCIFFTX and other bits also when i am only using receiver part of the code?

    Thank You for your reply though.

  • Bill,

    I just added this code in the main part of the code-

     while(1)
         {
              rdataB=ScibRegs.SCIRXBUF.all;
              if ( ScibRegs.SCIRXST.bit.RXRDY == 1)
              {
                      for(;;);
                   
              }
         }

    This part is just before the "void main()" ending.

    The problem i figured is that the receiver pin is not receiving the data as the execution doesn't go in side the if part.

    Is there any initialization error or any other other silly error that i am making.

    Thank You for your reply though.

  • Rachit Jain, 

                  you can refer this link, This link has TMS320F2812 SCIB Uart code. 

    https://www.pantechsolutions.net/tms320f2812/problem-in-uart-of-tms320f2812-1/410.html#p410

    Many Thanks,

    Thiyagarajan.S

  • I am getting a value of C09C in ScibRegs.SCIRXBUF.all. This means i am getting a framing and a parity error. So how do i tackle that.

  • Did you check on DSO, is the baud rate fine?

  • I have set the baud rate at 9600. I dont think there is any problem in the baud rate.

  • Rachit Jain said:
    Is it necessary to initialize the SCIFFTX

    Hello,

    I saw that you try to use FIFO (RXFIFO).

    How can you be able to use FIFO if you are not enable it?

    And to enable it, you should define the bit in SCIFFTX register (please see the picture below).

    I got this document from F28069, but I believe they are similar. Please check F2812 documentation for making it sure which bit you should set.

    Best regards,

    Maria

  • Yes i already did that initialization. I wrote that later in the code though and that is why i am getting C09C value in the RXBUF i.e SCIFFFE and SCIFFPE are set.

  • Rachit,

    I take it you don't enable interrupts before going into this loop?

    Also, do you disable the watchdog somewhere?

    Regards,

    Bill

  • Aha, OK, so now the RX FIFO interrupt occurs, right? (only the value isn't like expected).

    Btw, I saw that you enable the loop back in your previous code (ScibRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back ). I think you enter the character from PC, is it right? If so, this bit should be 0.

    Best regards,

    Maria

  • Ah! the code finally works and there is no better feeling.

    There was a one error in the loop and the loopback error.

    Thank you Maria

  • Oh, that's great! No better feeling indeed when our code works!

    Cheers!

    Best regards,

    Maria

  • Hi Rachit,

    I'm encountering the same problem as yours now. Was hoping if you can tell me what you changed in your code to fix it?

    Thank you so much
  • Please create a new thread if you would like further assistance on this issue. Your question has a better chance of being answered that way.