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
Hello,
The assert you are referring means that bytesEachWrite has a different value that any of the cases in the switch (1, 2, 3, 4). I recommend you to track down which part of your code is not setting bytesEachWrite correctly to know what is really happening in this situation.
Best regards,
Felipe