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.

TMS570LS3137: Halcogen code for SPI TX checking RX flag?

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Tool/software:

On the spiTransmitData function in the spi.c file, there's this check to see if the transmission has occured:

      /*SAFETYMCUSW 28 D MR:NA <APPROVED> "Hardware status bit read check" */
        while((spi->FLG & 0x00000100U) != 0x00000100U)
        {
        } /* Wait */

However, the documentation shows that the TX flag should be bit 9 (not 8 as in the code above). Page 1355 of spnu499c:

Also, the same flag is checked in the function spiGetData, which is the polling receiver, which further seems to point to a serious bug in the HalCoGen function. Am I missing something? Can someone confirm to me that the right approach is to change 0x0100 to 0x0200 in this function?

I'm using HalCoGen 04.07.01

  • Hi Gustavo Bruno,

    Actually, they are intentionally checking the Rx flag:

    If you verify the next line after this checking, they are reading the Receive buffer, right?

    Actually, SPI is a full duplex communication right, i mean transmission and reception will happen in parallel. That means if we send a frame then we will receive another frame in parallel.

    And spiTransmitData function will only transmit data in polling mode, so after sending a frame it should read and ignore the received frame. If we didn't read the receive buffer after sending a frame, then for the next frame transfer we will get the receive overrun error as highlighted below:

    And once this receive overrun flag sets then we don't send any further data:

    And we no need to check TXINTFLAG again because as we discussed it is a full duplex communication, so if we received a frame means the other frame in DAT1 register also shifted out.

    Instead of just reading and ignoring receive data, if you want to store the receive data also in other buffer then please use the spiTransmitAndReceiveData function instead of spiTransmitData  function.

    As you can see in this function the receive data is also storing in another buffer instead of just read and ignore.

    --
    Thanks & regards,
    Jagadish.