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.

AM2634: In MCSPI tx/rx transfer, last rx bytes are not read at EOW

Part Number: AM2634

Hello Support,

I'm updating our code to use SDK 09.01 and going through the patches that we applied to 08.06. One of them was added by an engineer who is no longer here at the company. Their comment was that this patch "catches a corner case in MCSPI tx/rx transfer where last rx bytes are not read at EOW". Any comments on this patch? Is, or was, this a know issue? Maybe it's been addressed in some other section of the code?

Thanks,
Jon

---
source/drivers/mcspi/v0/mcspi_v0.c | 31 +++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/source/drivers/mcspi/v0/mcspi_v0.c b/source/drivers/mcspi/v0/mcspi_v0.c
index 58272c4..20109b0 100644
--- a/source/drivers/mcspi/v0/mcspi_v0.c
+++ b/source/drivers/mcspi/v0/mcspi_v0.c
@@ -931,7 +931,7 @@ static int32_t MCSPI_transferControllerPoll(MCSPI_Object *obj,
{
int32_t status = SystemP_SUCCESS;
uint32_t baseAddr, chNum;
- uint32_t numWordsToWrite, txEmptyMask, irqStatus;
+ uint32_t numWordsToWrite, txEmptyMask, irqStatus, chStat;

baseAddr = obj->baseAddr;
chNum = chObj->chCfg.chNum;
@@ -986,6 +986,35 @@ static int32_t MCSPI_transferControllerPoll(MCSPI_Object *obj,
MCSPI_fifoWrite(baseAddr, chObj, 1);
}
}
+
+ irqStatus = CSL_REG32_RD(baseAddr + CSL_MCSPI_IRQSTATUS);
+
+ if ((irqStatus & CSL_MCSPI_IRQSTATUS_EOW_MASK) == CSL_MCSPI_IRQSTATUS_EOW_MASK)
+ {
+ /* Clear the EOW interrupt. */
+ CSL_REG32_WR(baseAddr + CSL_MCSPI_IRQSTATUS, CSL_MCSPI_IRQSTATUS_EOW_MASK);
+
+ if (MCSPI_TR_MODE_RX_ONLY != chObj->chCfg.trMode)
+ {
+ if (transaction->count == chObj->curTxWords)
+ {
+ do{
+ /* Wait for end of transfer. */
+ chStat = MCSPI_readChStatusReg(baseAddr, chNum);
+ }while ((chStat & CSL_MCSPI_CH0STAT_EOT_MASK) == 0);
+
+ /* read the last data if any from Rx FIFO. */
+ if (transaction->count != chObj->curRxWords)
+ {
+ /* This is a corner case. EOW is set at the end of transmission.
+ * the reception is not complete by the time we are processing EOW.
+ * Read the remaining bytes.
+ */
+ MCSPI_fifoRead(baseAddr, chObj, (transaction->count - chObj->curRxWords));
+ }
+ }
+ }
+ }
}
}
else
--