情景:
在一个任务里面,使用 for 或者 while 循环调用 SPI 操作[读写] FLASH(W25Q128),但是该循环操作未超过看门狗复位时间。
问题:
FreeRTOS系统重启(看门狗),调试发现在任务切换函数和SPI读写函数循环。
{
if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) )
{
/* Add the task to the suspended task list instead of a delayed task
list to ensure it is not woken by a timing event. It will block
indefinitely. */
vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xStateListItem ) );
}
else
{
/* Calculate the time at which the task should be woken if the event
does not occur. This may overflow but this doesn't matter, the
kernel will manage it correctly. */
xTimeToWake = xConstTickCount + xTicksToWait;
/* The list item will be inserted in wake time order. */
listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xStateListItem ), xTimeToWak

博客讲述在FreeRTOS系统中,任务里循环调用SPI操作FLASH时,系统出现看门狗重启问题,调试发现任务在切换函数和SPI读写函数间循环。推测是任务切换导致SPI读写错误,通过开关任务级临界段阻止任务调度解决卡死问题,后将临界段放整体读写函数解决读取错误,还可使用调度锁。
读写错误问题解决记录&spm=1001.2101.3001.5002&articleId=109741257&d=1&t=3&u=88c5670ef8da4cc3b65f3f5eb49cdcde)
96

被折叠的 条评论
为什么被折叠?



