Mohammad Aldawsari
Mohammad Aldawsari

Reputation: 31

NVIC System Reset fails

I’m using STM32f767zi with FreeRTOS kernel. I have two task:

1- one is triggered by a task notification from an interrupt every 100ms and receives some data through TCP.

2- the other task is handling some requests from user.

Now, if task-2 request for a system reset using NVIC_SystemReset API, system reset fails and every things hangs. When I run debugger, it seems it hangs in vPortRaiseBASEPRI. In disassembly, that is a few lines after vTaskNotifyFromISR which is the notification function I used for task-1.

When I remove that task notification and use just a flag in the interrupt, the system reset works fine. However, I think this way consumes the processor cycles and will not be efficient.

I tried to disable interrupts portDISABLE_INTERRUPT, tasks vTaskSuspendAll or enter critical taskENTER_CRITICAL but nothing work.

I did a way around method by requesting to portDISABLE_INTERRUPT in an independent request (so that any pended interrupt or “notification” can finish), then sending system reset in another request. This one works, however, it is not safe because the user can (by mistake) do the system reset before disabling interrupts.

Note that when I do hardware reset (push button on board) it works fine?!

So, any idea how to solve this problem? how to reset the board by software without that issue?

Upvotes: 0

Views: 2285

Answers (2)

Mohammad Aldawsari
Mohammad Aldawsari

Reputation: 31

The problem solved by simply adding some delay after disabling task-1 interrupt:

NVIC_DisableIRQ(IRQn);
vTaskDelay(xTicksToDelay);
NVIC_SystemReset();

I still don't know if this solved the root cause.

Upvotes: 0

0___________
0___________

Reputation: 68013

it is not system reset as system reset works always.

From the symptoms - you have wrong interrupt priorities set. All the used ones have to be lower the sysPENDV interrupt. Otherwise the context switch cannot happen (as this interrupt will not pre-empt the current one) and the result is as you observe. https://www.freertos.org/RTOS-Cortex-M3-M4.html

enter image description here

I tried to disable interrupts portDISABLE_INTERRUPT, tasks vTaskSuspendAll or enter critical taskENTER_CRITICAL but nothing work.

Do not disable interrupt if you do not understand how the RTOS works and what are consequences of it.

Upvotes: 1

Related Questions