AnsweredAssumed Answered

Problem with lpspi + Freertos

Question asked by Mit_3000GT_VR4 on Jun 25, 2020
Latest reply on Jun 30, 2020 by Felipe García

Hi,

I have problem with lpspi driver from SDK.

It sometimes generates an assert. Tracing, It comes to this function. (copy from the SDK driver)

static uint32_t LPSPI_CombineWriteData(uint8_t *txData, uint8_t bytesEachWrite, bool isByteSwap)

{

assert(txData != NULL);

uint32_t wordToSend = 0U;

switch (bytesEachWrite)
{
case 1:
wordToSend = *txData;
++txData;
break;

case 2:
if (!isByteSwap)
{
wordToSend = *txData;
++txData;
wordToSend |= (unsigned)(*txData) << 8U;
++txData;
}
else
{
wordToSend = (unsigned)(*txData) << 8U;
++txData;
wordToSend |= *txData;
++txData;
}

break;

case 3:
if (!isByteSwap)
{
wordToSend = *txData;
++txData;
wordToSend |= (unsigned)(*txData) << 8U;
++txData;
wordToSend |= (unsigned)(*txData) << 16U;
++txData;
}
else
{
wordToSend = (unsigned)(*txData) << 16U;
++txData;
wordToSend |= (unsigned)(*txData) << 8U;
++txData;
wordToSend |= *txData;
++txData;
}
break;

case 4:
if (!isByteSwap)
{
wordToSend = *txData;
++txData;
wordToSend |= (unsigned)(*txData) << 8U;
++txData;
wordToSend |= (unsigned)(*txData) << 16U;
++txData;
wordToSend |= (unsigned)(*txData) << 24U;
++txData;
}
else
{
wordToSend = (unsigned)(*txData) << 24U;
++txData;
wordToSend |= (unsigned)(*txData) << 16U;
++txData;
wordToSend |= (unsigned)(*txData) << 8U;
++txData;
wordToSend |= *txData;
++txData;
}
break;

default:
assert(false);                                          // ASSERT RIGHT HERE
break;
}
return wordToSend;

}

Please help if you have the same problem.

Thanks

Outcomes