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.

TMS320F28055: SCI-C RX Interrupt not working

Part Number: TMS320F28055

Hi,

I import UART interrupt loopback example based on SCI-A . It is working OK. I convert into SCI-C. when data is received, it is not reached at the interrupt  vector. 

I set   interrupt group  for SCI-C:

PieCtrlRegs.PIEIER8.bit.INTx5=1;
PieCtrlRegs.PIEIER8.bit.INTx6= 1;

my code as below. please help me.

Kind Regards-

Sudip


#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

#define CPU_FREQ 60E6
#define LSPCLK_FREQ (CPU_FREQ/4)
#define SCI_FREQ 100E3
#define SCI_PRD ((LSPCLK_FREQ/(SCI_FREQ*8))-1)

// Prototype statements for functions found within this file.
interrupt void scicTxFifoIsr(void);
interrupt void scicRxFifoIsr(void);

// Global variables
Uint16 sdataA[2]; // Send data for SCI-A
Uint16 rdataA[2]; // Received data for SCI-A
Uint16 rdata_pointA; // Used for checking the received data

void main(void)
{
Uint16 i;


InitSysCtrl();

EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO39 = 0; // Enable pull-up for GPIO39 (SCIRXDC)
GpioCtrlRegs.GPBPUD.bit.GPIO42 = 0; // Enable pull-up for GPIO42 (SCITXDC)
GpioCtrlRegs.GPBQSEL1.bit.GPIO39 = 3; // Asynch input GPIO39 (SCIRXDC)
GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 2; // Configure GPIO39 for SCIRXDC
GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 2; // Configure GPIO42 for SCITXDC
EDIS;

DINT;
InitPieCtrl();
InitPieVectTable();
IER = 0x0000;
IFR = 0x0000;


EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SCIRXINTC = &scicRxFifoIsr;
PieVectTable.SCITXINTC = &scicTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers


ScicRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset

ScicRegs.SCICTL2.bit.TXINTENA = 1;
ScicRegs.SCICTL2.bit.RXBKINTENA = 1;

ScicRegs.SCICCR.all = 0x0007;
ScicRegs.SCICCR.bit.LOOPBKENA =0; // 1; // Enable loop back

ScicRegs.SCILBAUD=0x00C2;

ScicRegs.SCIFFRX.all = 0x0022;
ScicRegs.SCIFFRX.bit.RXFIFORESET = 1;
ScicRegs.SCIFFRX.bit.RXFFIENA=1;

ScicRegs.SCIFFCT.all = 0x00;

ScicRegs.SCIFFTX.all = 0xC022;
ScicRegs.SCIFFTX.bit.TXFIFOXRESET = 1;

////////////////////////////////////////////
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

PieCtrlRegs.PIEIER8.bit.INTx5=1;
PieCtrlRegs.PIEIER8.bit.INTx6= 1;

IER = 0x100; // Enable CPU INT
EINT;

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

void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}

interrupt void scicTxFifoIsr(void)
{
Uint16 i;
for(i= 0; i < 2; i++)
{
ScicRegs.SCITXBUF = sdataA[i]; // Send data
}

for(i= 0; i < 2; i++) //Increment send data for next cycle
{
sdataA[i] = (sdataA[i]+1) & 0x00FF;
}

ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1; // Clear SCI Interrupt flag
PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ACK
}

interrupt void scicRxFifoIsr(void)
{
Uint16 i;
for(i = 0; i < 2; i++)
{
rdataA[i] = ScicRegs.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;

ScicRegs.SCIFFRX.bit.RXFFOVRCLR = 1; // Clear Overflow flag
ScicRegs.SCIFFRX.bit.RXFFINTCLR = 1; // Clear Interrupt flag

PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ack
}

  • Hi Sudip,

    The code looks good. 

    when data is received, it is not reached at the interrupt  vector. 

    Are you saying that there is data in the SCIRXBUF but the interrupt never occurs? Does the TX interrupt occur?

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thank you for your response. yes you are correct. when I am sending data, it is not going  tx interrupt vector. as well as when just receive data from pc terminal through FTDI, pointer is not reaches to the RX interrupt function/vector. but without interrupt or just polling method echo character is working fine.

    and FYI, same procedure SCI-B is working with interrupt in a single shot. just i changed pie vector bit.

    only SCI-C issue.

    kind regards-

    sudip

  • Sudip,

    Thank you for clarifying. 

    and FYI, same procedure SCI-B is working with interrupt in a single shot. just i changed pie vector bit.

    only SCI-C issue.

    I will test this tomorrow on hardware myself to see if I can duplicate the same issue. I'll reply back as soon as I can.

    Best Regards,

    Marlyn

  • Hi Sudip,

    I was not able to get the right hardware today but will try again tomorrow to see if I can get ahold of the F2805x device. I will keep you updated.

    Best Regards,

    Marlyn

  • Sudip,

    I am not able to go to the office at the moment. Hopefully by next week I will be able to go and acquire the right hardware. I apologize for the delay in confirming this issue from our side.

    Best Regards,

    Marlyn

  • ok, No issue. Thank you for your response.

  • Hi Sudip, 

    Thank you for your patience. I am still working on replicating this issue and will keep you posted. 

    Best Regards,

    Marlyn

  • Hi Marlyn,

    ok.

    Good to get solution ASAP. still  we are in same place  with this issue.

    Best Regards,

    sudip

  • Thank you Sudip, I will prioritize this. 

    Best Regards,

    Marlyn

  • Hi Sudip,

    The following lines need to be changed in the following way:

    // Within main.c
    IER = 0x100; // Enable CPU INT   -> IER = 0x80;
    
    // In the TX ISR
    PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ACK  -> PieCtrlRegs.PIEACK.all |= 0x80;
    
    // In the RX ISR
    PieCtrlRegs.PIEACK.all |= 0x100; // Issue PIE ack  -> PieCtrlRegs.PIEACK.all |= 0x80;
    
    

    In the PIE, SCI-C RX and TX interrupts are in Group 8, so you need to change these locations in the code to setup the IER and ACK correctly.

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Thank you so much for your response.

    I tried  as you provided. But still remain the same issue.  when I am sending, it is not reaching interrupt vector to send the data.

    I have a request. Like SCIA example  under CCS , can you provide us a complete example code on SCIC?. just for TX/RX demo. That would be great for us who is suffering SCIC interrupt issue.

    FYI, just we import SCIA example build and run without an issue.

    Best Regards-

    sudip

  • Hi Sudip,

    Yes, I am attaching the configuration I used for SCI-C that works for me. Please test it.

    //
    // Included Files
    //
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    #define CPU_FREQ    60E6
    #define LSPCLK_FREQ (CPU_FREQ/4)
    #define SCI_FREQ    100E3
    #define SCI_PRD     ((LSPCLK_FREQ/(SCI_FREQ*8))-1)
    
    // Prototype statements for functions found within this file.
    interrupt void scicTxFifoIsr(void);
    interrupt void scicRxFifoIsr(void);
    void scic_fifo_init(void);
    void error(void);
    
    // Global variables
    Uint16 sdataA[2];    // Send data for SCI-C
    Uint16 rdataA[2];    // Received data for SCI-C
    Uint16 rdata_pointA; // Used for checking the received data
    Uint16 enteredRXISR;
    Uint16 enteredTXISR;
    
    void main(void)
    {
        Uint16 i;
    
        //
        // Step 1. Initialize System Control:
        // PLL, WatchDog, enable Peripheral Clocks
        // This example function is found in the F2805x_SysCtrl.c file.
        //
        InitSysCtrl();
    
        //
        // Step 2. Initialize GPIO:
        // This example function is found in the F2805x_Gpio.c file and
        // illustrates how to set the GPIO to it's default state.
        // InitGpio();
        // Setup only the GP I/O only for SCI-A and SCI-B functionality
        // This function is found in F2805x_Sci.c
        //
        InitSciGpio();
    
        //
        // 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 F2805x_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 F2805x_DefaultIsr.c.
        // This function is found in F2805x_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.SCIRXINTC = &scicRxFifoIsr;
        PieVectTable.SCITXINTC = &scicTxFifoIsr;
        EDIS;   // This is needed to disable write to EALLOW protected registers
    
        //
        // Step 4. Initialize all the Device Peripherals:
        //
        scic_fifo_init();  // Init SCI-C
    
        //
        // 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;
            rdataA[i] = 0;
        }
    
        rdata_pointA = sdataA[0];
        enteredRXISR = 0;
        enteredTXISR = 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
    
        PieCtrlRegs.PIEIER8.bit.INTx5=1;   //SCI-C
        PieCtrlRegs.PIEIER8.bit.INTx6= 1;  //SCI-C
    
        IER = 0x80; // Enable CPU INT
        EINT;
    
        //
        // Step 6. IDLE loop. Just sit and loop forever (optional):
        //
        for(;;);
    }
    
    void error(void)
    {
        asm("     ESTOP0");                 // Test failed!! Stop!
        for (;;);
    }
    
    interrupt void scicTxFifoIsr(void)
    {
        enteredTXISR = enteredTXISR +1;
        Uint16 i;
        for(i= 0; i < 2; i++)
        {
           ScicRegs.SCITXBUF = sdataA[i];     // Send data
        }
    
        for(i= 0; i < 2; i++)                 //Increment send data for next cycle
        {
           sdataA[i] = (sdataA[i]+1) & 0x00FF;
        }
    
        ScicRegs.SCIFFTX.bit.TXFFINTCLR = 1;  // Clear SCI Interrupt flag
        PieCtrlRegs.PIEACK.all |= 0x80;      // Issue PIE ACK
    }
    
    interrupt void scicRxFifoIsr(void)
    {
        enteredRXISR = enteredRXISR + 1;
        Uint16 i;
        for(i = 0; i < 2; i++)
        {
           rdataA[i] = ScicRegs.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;
    
        ScicRegs.SCIFFRX.bit.RXFFOVRCLR = 1;   // Clear Overflow flag
        ScicRegs.SCIFFRX.bit.RXFFINTCLR = 1;   // Clear Interrupt flag
    
        PieCtrlRegs.PIEACK.all |= 0x80;       // Issue PIE ack
    }
    
    void scic_fifo_init()
    {
        ScicRegs.SCICCR.all = 0x0007;   // 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 = 1;
        ScicRegs.SCICTL2.bit.RXBKINTENA = 1;
        SciaRegs.SCIHBAUD = SCI_PRD;
        ScicRegs.SCILBAUD = SCI_PRD;
        ScicRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop back
        ScicRegs.SCIFFTX.all = 0xC022;
        ScicRegs.SCIFFRX.all = 0x0022;
        ScicRegs.SCIFFCT.all = 0x00;
    
        ScicRegs.SCICTL1.all = 0x0023;     // Relinquish SCI from Reset
        ScicRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
        ScicRegs.SCIFFRX.bit.RXFIFORESET = 1;
    }
    
    //
    // End of file.
    //
    

    Best Regards,

    Marlyn

  • Hi Marlyn,

    Yes, Finally, It is working as expected.

    your complete code helped me to find out the issue(proper interrupt group enabling).

    Thank you so much for your help and support.

    I have one suggestion. it would be great, if  your complete code is kept under serial port example (inside the resource explorer)

    Best Regards-

    sudip