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.

AWR1243: SPI Little-endian format

Part Number: AWR1243

I am reading the documentation AR1xx_Radar_Interface_Control, specifically the sections regarding the radar message structure (section 2.3) through the SPI message sequence (section 3.2). I am a little bit confused about the byte order in which to send data.

This paragraph:

states that message header and message data that is larger than one byte should be sent in little-endian byte order ie. the least significant byte is sent first. Further down in the document, there is a diagram given that demonstrates sending a SPI message:

It demonstrates sending the SYNC word 0x43211234 by first sending 0x1234 and then sending 0x4321. This suggests breaking a 4B field into two 2B chunks, and sending each 2B chunk in little-endian form.

My question is: if I wanted to transmit a 4B field in the message, 0x12345678, in what byte order should it be sent? Should it be sent as (0x8765, 0x4321), or as (0x4321, 0x8765)?

  • Hi,

    The answer will also depend on the software driver used on the host. You should connect a logic analyzer and check the signal.

    Notice in your example that 0x1234 is 2 bytes

    Thank you
    Cesar
  • Cesar,

    Your response does not address my question at all. I have posed my question as clearly as I can. If you do not understand something, please do ask for clarification.

    Antonio
  • Hi,

    Yes, I was not clear why you were swapping half bytes in your example.

    I think that this is what the example tries to communicate.


    1) the SYNC 4 byte patterns are stored in little endian format in memory (see "Section 2.3.1 SYNC", Revision 0.95)
    2) SPI word length should be 16-bit (Figure 3.2 Note 5, Revision 0.95)
    3) SPI will send little endian 16-bit first. For SYNC word 0x43211234, the SPI will send first the 16-bit word 0x1234

    Based on this understanding, I don't think the Note in the documentation is correct because the SPI is configured in 16-bit mode and not 8-bit mode

    If you are using a little endian host processor you should not be concerned by the order

    WIll check with the document writer and will get back to you

    thank you
    Cesar
  • Thanks, Cesar. That was my understanding as well. 

  • Cesar,

    Let me make sure I understand everything. Here is my understanding of how the protocol should work:

    This interpretation would also be consistent with how the SYNC word is sent, as shown in Figure 3.2 we discussed above. Can you confirm whether this is correct, or if we have a conceptual mistake? 

    Thanks,

    Antonio

  • Hello Antonio,

    The data should be sent in the same order that it is stored, it should not be rearranged from memory as it is sent. When the data is sent over SPI, it start with the first address in the buffer and send in order from there. I would recommend to try running the SPI test code and observing how the data is sent as this will give you the clearest picture.

    The test code is located at :

    C:\ti\mmwave_sdk_<sdk_version_number>\packages\ti\drivers\spi\test

    You can also take a deeper look at the driver, located one directory above from the previous link. Data transferred over SPI uses the SPI_Transfer() function which uses a SPI_Transaction structure that contains a pointer to transmit buffer.

    Regards,

    Adrian