Problem with lpspi + Freertos

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with lpspi + Freertos

551 Views
Mit_3000GT_VR4
Contributor II

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

Labels (1)
Tags (1)
0 Kudos
1 Reply

501 Views
FelipeGarcia
NXP Employee
NXP Employee

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

0 Kudos