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.

Compiler/TMS320F28027: TMS320F28027 issue SPI

Part Number: TMS320F28027


Tool/software: TI C/C++ Compiler

Hi,

I'm working with TMS320F28027, and I want to set up the spi interface to work with a raspberry pi. The issue is that the RXFFIENA register goes high once, then the interrupt is activated, but the register never goes low. It doesn't enter the callback anymore, and I think it is because of the permanent high state of that register. So I would thank any help to find why is this happening.

The other issue is that the transmit callback never enters.

This is my code.

void SPIa_Init(void (*tx_int)(void), void (*rx_int)(unsigned char))
  {


   EALLOW ;

   SpiaRegs.SPICCR.bit.SPISWRESET = 0;  // Reset condition

   SpiaRegs.SPICCR.bit.CLKPOLARITY = 1; // Falling edge
   SpiaRegs.SPICCR.bit.SPICHAR = 7;  // Character length 8 bits

   SpiaRegs.SPICTL.bit.MASTER_SLAVE = 0;    // Configured as slave

   SpiaRegs.SPICTL.bit.TALK = 1;    // Disable Transmit Path

   SpiaRegs.SPIFFTX.bit.SPIFFENA = 1;   /* SPI_A FIFO mode*/

   SpiaRegs.SPIFFRX.bit.RXFFIL = 4;      // Set RX FIFO level to 0
   SpiaRegs.SPIFFRX.bit.RXFFIENA = 1;

   spia_rx_callback = rx_int ;
   spia_tx_callback = tx_int;

   SpiaRegs.SPICCR.bit.SPISWRESET = 1;

   EDIS;

   DINT;

//    Enable the SCI receive interrupt
   Hwi_create(72, SPIARX_ISR, NULL, NULL); // Enable SPIRXINTA in PIE group 6
   Hwi_create(73, SPIATX_ISR, NULL, NULL); // Enable SPIRXINTA in PIE group 6

   EINT;                                    // Enable Interrupts at the CPU level

   return ;
}

void SPIARX_ISR (UArg arg)
{
   rdata[1] = SpiaRegs.SPIRXBUF; // Slave reads data
   rdata[2] = SpiaRegs.SPIRXBUF; // Slave reads data
   rdata[3] = SpiaRegs.SPIRXBUF; // Slave reads data
//   rdata[4] = SpiaRegs.SPIRXBUF; // Slave reads data

//   if(spia_rx_callback != 0)
//     (*spia_rx_callback)(rdata[1]);               //sends the data to a function pointed by sci_callback
   EALLOW;

   SpiaRegs.SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
//   PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
   EDIS;
}

void SPIATX_ISR (UArg arg)
{
   //if(spia_tx_callback != 0)
   //  (*spia_tx_callback)();                    // execute a function pointed by sci_callback
}

void SPIATX_ISR (UArg arg)
{
    SpiaRegs.SPITXBUF = sdata[1]; // Slave transmits data

    SpiaRegs.SPIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ACK
   //if(spia_tx_callback != 0)
   //  (*spia_tx_callback)();                    // execute a function pointed by sci_callback
}