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/TMS320F28335: SCI RX interrupt not triggering

Part Number: TMS320F28335
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi,

I am trying to use SCIA Rx interrupt to save a received data in a variable (Received Char). The data is sent through the same DSP using Tx pin of SCIA.

I see that in the watch window the value of RXRDY pin goes 1 still the Rx interrupt does not trigger and it shows me an OE error as i am sending the data continuously. Am i missing something in the initialization?

or setting up my system?

Rx_int.txt
// TI File $Revision: /main/11 $
// Checkin $Date: May 12, 2008   14:24:12 $
//###########################################################################
//
// FILE:    Example_2833xSci_FFDLB.c
//
// TITLE:   DSP2833x Device SCI FIFO Digital Loop Back Test.
//
// ASSUMPTIONS:
//
//    This program requires the DSP2833x header files.
//
//    This program uses the internal loop back test mode of the peripheral.
//    Other then boot mode pin configuration, no other hardware configuration
//    is required.
//
//    As supplied, this project is configured for "boot to SARAM"
//    operation.  The 2833x Boot Mode table is shown below.
//    For information on configuring the boot mode of an eZdsp,
//    please refer to the documentation included with the eZdsp,
//
//       $Boot_Table:
//
//         GPIO87   GPIO86     GPIO85   GPIO84
//          XA15     XA14       XA13     XA12
//           PU       PU         PU       PU
//        ==========================================
//            1        1          1        1    Jump to Flash
//            1        1          1        0    SCI-A boot
//            1        1          0        1    SPI-A boot
//            1        1          0        0    I2C-A boot
//            1        0          1        1    eCAN-A boot
//            1        0          1        0    McBSP-A boot
//            1        0          0        1    Jump to XINTF x16
//            1        0          0        0    Jump to XINTF x32
//            0        1          1        1    Jump to OTP
//            0        1          1        0    Parallel GPIO I/O boot
//            0        1          0        1    Parallel XINTF boot
//            0        1          0        0    Jump to SARAM	    <- "boot to SARAM"
//            0        0          1        1    Branch to check boot mode
//            0        0          1        0    Boot to flash, bypass ADC cal
//            0        0          0        1    Boot to SARAM, bypass ADC cal
//            0        0          0        0    Boot to SCI-A, bypass ADC cal
//                                              Boot_Table_End$
//
// DESCRIPTION:
//
//    This test uses the loopback test mode of the SCI module to send
//    characters starting with 0x00 through 0xFF.  The test will send
//    a character and then check the receive buffer for a correct match.
//
//          Watch Variables:
//                LoopCount      Number of characters sent
//                ErrorCount     Number of errors detected
//                SendChar       Character sent
//                ReceivedChar   Character recieved
//
//
//###########################################################################
//
// Original Author: S.S.
//
// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
// $Release Date: August 4, 2009 $
//###########################################################################


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

// Prototype statements for functions found within this file.
void scia_loopback_init(void);
void scia_fifo_init(void);
void scia_xmit(int a);
void error();
interrupt void scia_rx_isr(void);
interrupt void scia_tx_isr(void);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;
Uint16 SendChar;
Uint16 ReceivedChar;

void main(void)
{
    

// Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP2833x_SysCtrl.c file.
	InitSysCtrl();

// Step 2. Select GPIO for the device or for the specific application:
// This function is found in the DSP2833x_Gpio.c file.
// InitGpio(); skip this as this is example selects the I/O
// for SCI-A in this file itself
   InitSciGpio();

// Step 3. Initialize PIE vector table:
// The PIE vector table is initialized with pointers to shell Interrupt
// Service Routines (ISR).  The shell routines are found in DSP2833x_DefaultIsr.c.
// Insert user specific ISR code in the appropriate shell ISR routine in
// the DSP28_DefaultIsr.c file.

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

      // Initialize Pie Control Registers To Default State:
      // This function is found in the DSP2833x_PieCtrl.c file.
	  // InitPieCtrl();  PIE is not used for this example

      // Initialize the PIE Vector Table To a Known State:
      // This function is found in DSP2833x_PieVect.c.
      // This function populates the PIE vector table with pointers
      // to the shell ISR functions found in DSP2833x_DefaultIsr.c.
	  InitPieVectTable();

	  EALLOW;
	  PieVectTable.SCIRXINTA = &scia_rx_isr;
      PieVectTable.SCITXINTA = &scia_tx_isr;
	  EDIS;

      // Enable CPU and PIE interrupts
      // This example function is found in the DSP2833x_PieCtrl.c file.
      EnableInterrupts();
  
      IER|= M_INT9;

   	PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
    PieCtrlRegs.PIEIER9.bit.INTx2 = 1;

	EINT;
	ERTM;
  
 // EALLOW;
  //SysCtrlRegs.LOSPCP.bit.LSPCLK= 0;
  //EDIS;


// Step 4. Initialize all the Device Peripherals to a known state:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals(); skip this for SCI tests

// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:

    LoopCount = 0;
    ErrorCount = 0;

  //  scia_fifo_init();	   // Initialize the SCI FIFO
	
    scia_loopback_init();  // Initalize SCI for digital loop back
    
    // Note: Autobaud lock is not required for this example

    // Send a character starting with 0
    SendChar = 10;

// Step 6. Send Characters forever starting with 0x00 and going through
// 0xFF.  After sending each, check the recieve buffer for the correct value

	for(;;)
    {
    scia_xmit(SendChar);
      
   // SendChar=SciaRegs.SCIRXEMU; 
   // while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO

       // Check received character
    // ReceivedChar=SciaRegs.SCIRXBUF.all;
	 //scia_xmit(ReceivedChar);
   //  if(ReceivedChar != SendChar) error();
     DELAY_US(10000);
       // Move to the next character and repeat the test
     SendChar++;
     
     // SendChar &= 0x00FF;  // Limit the character to 8-bits
       LoopCount++;
    }

}

interrupt void scia_rx_isr(void)

{
  ReceivedChar=SciaRegs.SCIRXBUF.all;
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
}

interrupt void scia_tx_isr(void)

{
}

// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:

void error() 
{

      ErrorCount++;
//    asm("     ESTOP0");  // Uncomment to stop the test here
//    for (;;);

}

// Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_loopback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

 	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.all =0x0003;
	SciaRegs.SCICTL2.bit.TXINTENA =1;
	SciaRegs.SCICTL2.bit.RXBKINTENA =1;
    SciaRegs.SCIHBAUD    =0x0000;
    SciaRegs.SCILBAUD    =0x1000;
//	SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back
	SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
//	 EALLOW;
    // All Zones---------------------------------
    // Timing for all zones based on XTIMCLK = SYSCLKOUT
  //  XintfRegs.XINTCNF2.bit.XTIMCLK = 1;                      // to check system frequency
      // XCLKOUT is enabled
  //  XintfRegs.XINTCNF2.bit.CLKOFF = 0;
    // XCLKOUT = XTIMCLK
  //  XintfRegs.XINTCNF2.bit.CLKMODE = 0;  // 37.5MHZ
//	EDIS;
}



// Transmit a character from the SCI'
void scia_xmit(int a)
{
    SciaRegs.SCITXBUF=a;
}

// Initalize the SCI FIFO
void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    //SciaRegs.SCIFFRX.bit.RXFIFORESET = 0;
    SciaRegs.SCIFFRX.all=0x204f;
   // SciaRegs.SCIFFRX.bit.RXFFST= 0;
    SciaRegs.SCIFFCT.all=0x0;

}





//===========================================================================
// No more.
//===========================================================================



  • Ankit,

                    It looks like you have already used a ControlSuite example as a starting point, you used “scia_loopback”. That code shows you how to use the SCI module without interrupts, we also have an example in ControlSuite that demonstrates how to use the SCI module with interrupts “sci_loopback_interrupts”. Check that example, I think it will help you figure this problem out.

    Note: if you’re sending information from a second device you should  make sure to disable internal loopback!

     

    Regards,
    Cody

  • Ankit,
    have you found this information useful? Have you solved your issue?
    Regards,
    Cody
  • Hi Cody,

    thanks for pointing out the example using interrupts.
    I was going through the example and trying to understand when is it going into SCiaTxFifoIsr. According to the initialization it will go into the ISr if value of TXFFST is less then or equal to TXFFIL which is defined as 8. I understand how it goes into the interrupt for the first two times (value of TXFFST<= TXFFIL). However, i am not clear on how is the value of TXFFST reset and when. TXFIFOXRESET bit is set, so it should reanable FIFO operation but when?
  • Ankit,

    you can think to the TX interrupt like this: The SCI TX interrupt is a request from the SCI module saying "my FIFO is getting low(TXFFST<TXFFIL), and would I like some more values to send". TXFFST is not normally "reset", it is incremented anytime a message is added to the queue ,and decremented anytime a message is transmitted. If you set TXFIFORESET=0 the device will stop using the FIFO and set TXFFST =0, it will immediately resume using the FIFO when you set TXFIFORESET =1.


    Regards,
    Cody

  • HI Cody,

    thank you for the explanation. I think i get that part how interuppts are being generated. My issue was that i dont see when is the value of TXFFST is being decremented. I am using breakpoints in the code and run the code using step over so as to follow the exicution of the code. I see the value of TXFFST change from 00000 to 01000 in first cycle and from 01000 to 01111 in the second but i am not able to see it change back to 01000 using step over. However if i use run it changes to 01000 but i am not able to follow how it changed its value.
  • Ankit,

    it sounds like your emulation behavior is setup to immediately suspend operation on a debug halt. There are several behaviors you can configure, these are all outlined in the SCI Reference Guide. Take a look at the SCIPRI register if you would like to change the SCI's behavior on debug halts.

    Try this:

    Place a breakpoint at the beginning of your ISR.(at this point you should see a value less than or equal to your TXFFIL in TXFFST)

    Place a breakpoint in your ISR immediately after you add a value to the FIFO.(at this point you should be able to see that TXFFST has incremented)

    Of course if you give the device too much time after you add a value to the FIFO it will transmit another message, decrement TXFFST, and it will appear as if TXFFST was never incremented.

    Regards,

    Cody