How to properly feed WDT

Posts: 3
Joined: Fri Apr 26, 2019 6:39 am

How to properly feed WDT

Postby kimsunk » Thu May 16, 2019 5:12 am

  1. #include "esp_task_wdt.h"
  3. void setup() {
  5.   Serial.begin( 1000000 );
  6.   BaseType_t result = xTaskCreatePinnedToCore( handleOtherThings, "handleOtherThings", 20000, NULL, 1, NULL, 0 );
  7. }
  9. void handleOtherThings( void* param ) {
  11.   while( true ){
  13.     esp_task_wdt_reset();
  14.   }
  15. }
  16. void loop() {
  17.   // put your main code here, to run repeatedly:
  19. }
I want to use xTaskCreatePinnedToCore function to run two tasks on each core.

However, WDT reset keep triggered.

Nothing changes if I use yield() instead of esp_task_wdt_reset();

However, if i change esp_task_wdt_reset() to vTaskDelay( 10 / portTICK_PERIOD_MS ), then no more WDT reset, but I don't want 10ms delay for my task.

delay(1); also resets WDT timer but I also do not want it be delayed for 1ms.

delay( 0 ); do not reset WDT timer.

delayMicroseconds( 100 ); do not reset WDT timer.

What would be the minimal and proper way to reset WDT timer in ESP32-arduino?

Posts: 248
Joined: Tue Aug 21, 2018 5:28 am

Re: How to properly feed WDT

Postby boarchuz » Thu May 16, 2019 6:31 am

I understand that yield() should do the job. I suspect it's actually the loopTask causing your issues.

It's unclear if that's actually your loop() function or if you've cut it down to that for the sake of brevity. If that's actually it, could you try adding vTaskDelay(portMAXDELAY) to it?

Posts: 3589
Joined: Thu Nov 26, 2015 4:08 am

Re: How to properly feed WDT

Postby ESP_Sprite » Thu May 16, 2019 11:19 am

You misunderstand the purpose of esp_task_wdt_reset(). The esp-idf watchdog actually monitors multiple tasks, the most important one being the idle tasks. If these don't feed the watchdog in time, it means something is using up all the CPU power and for various reasons this is not good. (This is also why vTaskDelay() or yield() work: they allow the idle task to run.) esp_task_wdt_reset() does not reset the watchdog that watches the idle threads; instead, it is used to reset a watchdog that would be watching your thread. As the idle thread watchdog still times out, you still will get warnings.

Who is online

Users browsing this forum: No registered users and 8 guests