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.

TMS320F28069M: SPI receive problem

Part Number: TMS320F28069M


Greetings! I am using Instaspin lib and I am setting up my SPI interface. Here is my init sequence:

void HAL_setupSpiA(HAL_Handle handle)
{
  HAL_Obj   *obj = (HAL_Obj *)handle;

  SPI_reset(obj->spiAHandle);
  SPI_setMode(obj->spiAHandle,SPI_Mode_Master);
  SPI_setClkPhase(obj->spiAHandle,SPI_ClkPhase_Delayed);
  SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputFallingEdge_InputRisingEdge);
  SPI_enableTx(obj->spiAHandle);
  SPI_disableTxFifoEnh(obj->spiAHandle);
  SPI_setTxDelay(obj->spiAHandle,0x0000);
  SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x07D0));
  SPI_setCharLength(obj->spiAHandle,SPI_CharLength_8_Bits);
  SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free);
  SPI_enable(obj->spiAHandle);

  return;
}  // end of HAL_setupSpiA() function

And here is my spi_xfer function:

unsigned int spi_xfer(unsigned char data)
{
    SPI_write8(halHandle->spiAHandle, data);
    while(SPI_getTxFifoStatus(halHandle->spiAHandle)!=SPI_FifoStatus_Empty);
    unsigned int result=0;
    result = SPI_read(halHandle->spiAHandle);
    return result;
}

The problem is I am not receiving corrent data. I can see the data transfer with my logic analyser and there is a big difference. I am addressing an EEPROM and the init function from my controller is 0x9F,0xA5,0xA5,0xA5. And the EEPROM responds with 0xFF, 0xE7, 0x40, 0x14. I can see this with my logic analyser. The problem is that I`m receiving 0xFF, 0xF7, 0xA0 on the MCU(I don`t safe the first value which is dummy bite. Only the last 3). Any ideas what I am doing wrong?

Thanks!