You need to yield to FreeRTOS periodically which will also reset the watchdog timer. If you have a simple main loop application (e.g. you are only using one RTOS task) then this is a way to do that, but with the catch you have to release operation for the RTOS tick time (default 10mS):

	if (ResetWdtPrescaller1ms <= 0)
	{
		ResetWdtPrescaller1ms = 500;
		vTaskDelay(10 / portTICK_PERIOD_MS);	//Delay for 10mS (min possible to default portTICK_PERIOD_MS = 10 (10ms per FreeRTOS tick)
	}
		

If you don’t want to stall your main loop for 10mS every time then you can do this instead:

#include "esp_task_wdt.h"

//Before your main loop:
esp_task_wdt_add(NULL);  		// Register this task with the task watchdog. NULL=current task

//Inside your main loop:
	//----- EXIT TO THE IDLE TASK PERIODICALLY -----
	//Ensures the IDLE task watchdog will be reset and any other OS background tasks will be actioned
	if (ResetWdtPrescaller1ms <= 0)
	{
		ResetWdtPrescaller1ms = 500;
		esp_task_wdt_reset();		//Reset the watchdog without sleeping
		taskYIELD(); 				//Optionally yield so others can run, with minimal delay
	}
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *