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.

TMS320F28035: SPI : Data received by SPIDAT register not moving to SPIRXBUF buffer

Part Number: TMS320F28035
Other Parts Discussed in Thread: C2000WARE

I am trying to communicate and store data serially with AT45DB321E, a serial flash memory and everything works properly till data is received by the microcontroller.

I want to store output data from the slave into an array by directly storing receive buffer data to an array of defined size, but the buffer (SPIRXBUF) does not contain the data received by SPIDAT, which I'm checking with another array. The data received by SPIDAT in my set up is correct, but this data isn't being moved to SPIRXBUF, where it should be stored to read. I have included my configuration below.

    SpiaRegs.SPIFFTX.all = 0xE060;
    SpiaRegs.SPIFFRX.all = 0x6064;
    SpiaRegs.SPIFFCT.all = 0x0;
    SpiaRegs.SPICCR.bit.SPISWRESET = 0;
    SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
    SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
    SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
    SpiaRegs.SPICTL.bit.TALK = 1;
    SpiaRegs.SPICTL.bit.SPIINTENA = 1;
    SpiaRegs.SPIBRR = 0x007F;
    SpiaRegs.SPICCR.bit.SPICHAR = 0x7;
    SpiaRegs.SPISTS.bit.INT_FLAG = 0;
    SpiaRegs.SPIFFRX.bit.RXFFOVFCLR = 1;
    SpiaRegs.SPICCR.bit.SPILBK = 0;
    SpiaRegs.SPICCR.bit.SPISWRESET = 1;
    SpiaRegs.SPIPRI.bit.FREE = 0;

The pins are initialized using the SPI example program function InitSpiaGpio(). I am storing my data like this in receive FIFO interrupt:

a[i] = SpiaRegs.SPIRXBUF;
ab[i] = SpiaRegs.SPIDAT;

I have monitored all of the flags too and there are no instances of overrun, buffer full or overflow. How do I fix this problem?

  • Arjun,

    Did you probe your SPI pins? Did you confirm whether AT45DB321E is transmitting slave data?

    Regards,

    Manoj

  • Yes, I verified the slave out data both through the waveform and the data stored in ab[i] array with the data I have written into the slave. All the steps are working except received data from SPIDAT moving to SPIRXBUF. When the receive ISR runs, SPIRXBUF contains 0x00FF instead of the data received by SPIDAT.

  • Arjun,

    SPI configuration sequence of SPI registers is important for proper operation of SPI. I have changed your SPI configuration as shown below and try again.

        SpiaRegs.SPICCR.bit.SPISWRESET = 0;   // Reset SPI
        
        SpiaRegs.SPICCR.all  = 0x0007;          // Loopback mode disabled, 8-bit char
        SpiaRegs.SPICTL.all  = 0x001F;          // Master Transmit, Overrun interrupt, SPI interrupt
                                               // Clock Phase 1
        SpiaRegs.SPISTS.all  = 0x0000;
        SpiaRegs.SPIBRR.all  = 0x007F;
        SpiaRegs.SPIFFTX.all = 0xC022;    
        SpiaRegs.SPIFFRX.all = 0x0024;
        SpiaRegs.SPIFFCT.all = 0x0000;
        SpiaRegs.SPIPRI.all  = 0x0010;
        
        SpiaRegs.SPICCR.bit.SPISWRESET=1;  // Enable SPI

        SpiaRegs.SPIFFTX.bit.TXFIFO=1;
        SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;

    Did you already checkout C2000Ware SPI example available in below path?

    <C2000Ware>\device_support\f2803x\examples\c28\spi_loopback_interrupts

    So, you need to make sure to select emulation free run by setting SPIPRI.FREE = 1. I have made that change in your code.

    Regards,

    Manoj

  • Manoj,

    I made all the changes you suggested but the data is still not moving from SPIDAT to SPIRXBUF. I have gone through the example programs but found nothing helpful. The receive buffer constantly has FF stored in it.

  • Can you please send your source code?

    Regards,

    Manoj

  • Is this issue resolved? Were you able to figure out the issue?