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.

TMS570LS0432: Changing the data format of a SPI slave in run time

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN,

Hi,

I am using the TMS570LS0432 SPI2 port as SPI slave. I would like to change the data frame format of the SPI receiver during runtime.  I am using spiReceiveData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint16 * destbuff) function to receive the data.   I have two data formats set in HALCoGen and are defined in the code as shown below

dataconfig1_t.CS_HOLD = FALSE;
dataconfig1_t.WDEL = FALSE;
dataconfig1_t.DFSEL = SPI_FMT_1;
dataconfig1_t.CSNR = SPI_CS_0;

dataconfig2_t.CS_HOLD = FALSE;
dataconfig2_t.WDEL = FALSE;
dataconfig2_t.DFSEL = SPI_FMT_0;
dataconfig2_t.CSNR = SPI_CS_0;

The only difference in the formats is the Char length. The SPI_FMT_0 has the Char length of 16 bits and  SPI_FMT_1 has the Char length of  8 bits. I use dataconfig2_t by default and it works fine (i.e., 16 bits).  If I change the char length and try to receive the data, I do not get all data. I miss last 2 bytes. (i.e., if I have to recevie I only receive 8 bytes) .

Is it possible for the SPI receiver to change the data format during runtime?

Thanks & best regards,

sreekanth challa

  • Hello Sreekanth,

    The short answer is yes. When you pass in the parameter spiDAT1_t *dataconfig_t this is the value written to the SPIDAT1 register. The format will be whatever you define for the parameter. i.e., in one instance you would pass in dataconfig1 and in another dataconfig2. Which ever format is defined within the structs will be the ones loaded for that specific transmit event.