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.

TMS320F280025C: SPIDAT shift and SPIRXBUF problems

Part Number: TMS320F280025C
Other Parts Discussed in Thread: C2000WARE

Hi Champ, 

I am asking for my customer.

The F280025C which is a master, writes a series of data to an EEPROM(slave), and echo-back and read the data which was sent from MCU.

They are using FIFO without interrupt, and the transmission character length is 8 bit which is set in SPICHAR. 

Below screenshot is the register status when MCU is writing a series data (10, 9, 8, ..., 1) to EEPROM, and it is sure that EEPROM is echo-backing data (10, 9, 8, ..., 1) back on the probe.

As it could seen that 0A arrives in the SPIDAT shift register in LSB, it is supposed that the data should then be forwarded to the SPIRXBUF buffer, while SPIRXBUF is always 0x00FF.

So that when the SPIRXBUF is copied into a temporary variable stored in an array, the values in the array always remain 255.

EEPROM_read_page(ADDRESS_PAGE0, &data_to_read[0], 10);     //  Read data function is called  in main(); 

void EEPROM_read_page(uint16_t ADDRESS,uint16_t *Data, uint16_t N)   // The function of read data from SPIRXBUF
{
      uint16_t dummy_write = 0xFF00; 

      // push out command
      SpiaRegs.SPITXBUF = 0x0300      // READ OP CODE;
      SpiaRegs.SPITXBUF = (ADDRESS) & 0xff00;
      SpiaRegs.SPITXBUF = (ADDRESS<<8) & 0xff00;

      while (SpiaRegs.SPIFFRX.bit.RXFFST != 0)
      {
            dummy_read = SpiaRegs.SPIRXBUF;
       }

      for( uint16_t i=0 ; i<N ; i++)
      {
          SpiaRegs.SPITXBUF = dummy_write; 

          *(Data+i) =  0x00FF & SpiaRegs.SPIRXBUF;
       }

return;
}

Would the expert kindly tell me where the problem is in the code ?

And please briefly explain how is actually the SPIDAT copy data to SPIRXBUF in FIFO ?

Thanks and regards

  • Chen,

    Similar function is defined in spi_ex6_eeprom.c (<C2000Ware>\driverlib\f28002x\driverlib\f28002x\examples\spi). Please check them. 

    void readData(uint16_t address, uint16_t *data, uint16_t length, uint16_t txdly)
    {
    uint32_t base = SPIA_BASE;

    CS_LOW;

    // Send the READ opcode.
    SPI_transmitByte(base, READ);

    // Send EEPROM address to write data
    SPI_transmit16Bits(base, address);

    // Receive length number of bytes
    SPI_receiveNBytes(base, data, length, txdly);


    CS_HIGH;
    }

    Function such as SPI_transmitByte, SPI_transmit16Bits, SPI_receiveNBytes is defined in spi.c / spi.h in below path.

    Path: <C2000Ware>\driverlib\f28002x\driverlib\

    File: spi.c

    Regards,

    Manoj

  • Whatever you write to SPITXBUF register it transfers the data to SPIDAT register to transmit on SPIMOSI pin. In your code, you are immediately trying to read the SPIRXBUF immediately after you write to SPITXBUF that is the reason why you read the value you transmitted. You have to wait for SPIRX FIFO to be filled with some data before you read SPIRXBUF. You have wait for RXFIFO status register to be atleast non-zero (as it indicates the number of bytes received in SPI RX FIFO)