Problem with lpspi + Freertos

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with lpspi + Freertos

724 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
1 回复

674 次查看
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 项奖励
回复