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.

TMS570LS0914: SPI - alternate data formats with differnt polarity

Part Number: TMS570LS0914


Tool/software:

Hi,

I am using SPI5 in master mode along with several slaves. I need to alternate in between different data formats. 
Data-Format-0: 16 bit, Pol=0, Phase=0 => CLK finished off at low level:

Data-Format-1: 8 bit, Pol=1, Phase=0 
This causes a problem every time I switch from one data format to the other. For example, switching from data format 0 to data format 1.
The clock starts low, data (0x40, 0x0C, 0x00, 0x00, 0xE0) is misinterpreted:
 W

Writing the same data for a second time leads to correct data because the preceding packet ended with the clock in high state.

A similar problem occurs when switching back to data format 0, which expects the clock to start on a low level.
Is there a way to fix this behavior without sending packets twice?

 

Best Regards,

Juergen

  • Hi Juergen,

    As per my understanding, this issue is due to the below problem:

    If you try to switch the modes using transfer function directly, we will get problem because we are doing all the things (enabling chip select, sending data and changing the mode) at a time like as i highlighted in below pic.

    If we do like this then the mode will not shift properly, because data transfer and mode changing happening simultaneously. If we are writing same mode, then we don't have any problem because clock polarity and phase are same right.

    So, my suggestion will be, try to do as below:

    After your first transfer, don't call the second transfer function directly with new configuration. Instead of, after first transfer do disable the SPI and change the mode and reenable the SPI and then you can call the second transfer.

    Here disabling SPI is required before changing the mode is because, if you didn't disable the SPI and try to change the mode then it will initiate a transfer because you are writing to the DATA1 register (DATA1 register is common for data and configurations). So that is the reason you should need to disable the SPI and change the mode and then you can do the next transfer.

    This process is working fine on my end on RM46 board, i am just attaching my project for your reference and please try to follow the same method and let me know the result.

    SPI_DataFormat_Changing_InBetween_Issue_RM46.zip

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    thanks for your helpt, it works on my side too.

     

    Best Regards,

    Juergen