AnsweredAssumed Answered

Bug in SPI driver for LPC845 - SPI_MasterTransferBlocking

Question asked by tim99 on Sep 27, 2019
Latest reply on Oct 15, 2019 by JOE VIGNOLA

If you call the function SPI_MasterTransferBlocking with one of the flags kSPI_EndOfFrame, kSPI_EndOfTransfer or kSPI_ReceiveIgnore. the next time you call the SPI_MasterTransferBlocking without these flags, they will still be set.

The reason for this behavior is the line in the function SPI_MAsterTransferBlocking:

/* Read datawidth and ssel info from TXCTL. */

tx_ctrl = base->TXCTL & (SPI_TXCTL_LEN_MASK | SPI_TXCTL_RXIGNORE_MASK | SPI_TXCTL_EOF_MASK | SPI_TXCTL_EOT_MASK |

kSPI_SselDeAssertAll);

According to the comment, the intention is to keep the datawitdh and ssel, but all the above mentioned flags/bits are also read. To get the behavior as I would expect I need to change the line to:

tx_ctrl = base->TXCTL & (SPI_TXCTL_LEN_MASK | kSPI_SselDeAssertAll);

 

An example of when the function fails

 

/*Start Transfer*/

xfer.txData = Obuf;

xfer.rxData = tmp;

xfer.dataSize = LengthO;

xfer.configFlags = 0;

/* Transfer data in polling mode. */

SPI_MasterTransferBlocking(SPI_0_PERIPHERAL, &xfer);

 

/*Start Transfer*/

 

xfer.txData = NULL;

xfer.rxData = Ibuf;

xfer.dataSize = LengthI;

xfer.configFlags = kSPI_EndOfTransfer | kSPI_EndOfFrame;

/* Transfer data in polling mode. */

SPI_MasterTransferBlocking(SPI_0_PERIPHERAL, &xfer);

 

/*Start Transfer*/

xfer.txData = Obuf;

xfer.rxData = tmp;

xfer.dataSize = LengthO;

xfer.configFlags = 0;

/* Transfer data in polling mode. */

SPI_MasterTransferBlocking(SPI_0_PERIPHERAL, &xfer);

 

/*Start Transfer*/

 

xfer.txData = NULL;

xfer.rxData = Ibuf;

xfer.dataSize = LengthI;

xfer.configFlags = kSPI_EndOfTransfer | kSPI_EndOfFrame;

/* Transfer data in polling mode. */

SPI_MasterTransferBlocking(SPI_0_PERIPHERAL, &xfer);

 

The first call works as expected and the SSEL line is kept active. The second call works as expected where the SSEL line is set to inactive after the transmission. The third call fails where the SSEL line is set to inactive after the call as if the the flags EndOfTransfer and EndOfFrame were still set.

 

Please confirm if this is a bug or if I am using the driver wrong.

Attachments

Outcomes