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.

TMS570LC4357: How can we implement variable length MIBSPI Transfer Groups tied to the same Chip Select?

Part Number: TMS570LC4357
  • This is not a question looking for an answer, just a question with an answer that might help someone else.

As a working example let’s say that:

  • the SPI Master must be able to send 1, 2, and 5-byte messages.
  • the SPI Slave has a way to identify the messages as they roll in.
  • all of the messages have to be received by the same MIBSPI device. 

MIBSPI Master

  • For all outbound messages define a TG:
    • sized to match the message size.
    • associated with the same physical Chip Select.
  • When sending using the MIBSPI driver API:
    • specify the TG that matches the message you are trying to send.
    • the CS will go active low for the duration of the data send if CSHOLD is set.

MIBSPI Slave

  • Create a “Shadow” of the slave's Chip Select by tying it to GIOA[x].
  • Define single TG sized to fit the largest TG sent by the SPI Master.
  • Configure the GIOA[x] to notify on the rising edge of the Chip Select.
  • In the GIOA[x] notification callback
    • set GCR1.SPIEN = 0 to deactivate the MIBSPI[x] device.
    • set GCR1.SPIEN = 1 to reactivate MIBSPI[x], this is a partial reset of key registers and key to this working.
    • Use the MIBSPI API call to read the received data.
    • Identify the received message by examining its contents.

How does this work?

  • When the MIBSPI Master sends a 5-byte message
    • it is received and processed w/o errors and there is a TG Complete indication available. 
  • When the MIBSPI Slave receives a 1 or 2 byte message
    • there is no TG Complete indication, it's a partial message that needs to be read out immediately. 
    • the toggling 0->1 of GCR1.SPIEN in the notification callback finalizes the transfer and sets the received data pointer back to the start of the buffer.