Esp32s3 : Question about the Task Watch Dog Timer

ThomasESP32
Posts: 214
Joined: Thu Jul 14, 2022 5:15 am

Esp32s3 : Question about the Task Watch Dog Timer

Postby ThomasESP32 » Fri Jun 23, 2023 9:01 am

Good morning,

I have a question concerning the Task Watch Dog Timer please.
I have read that when initializing the Task Watch Dog Timer, only the Idle task of each CPU was monitored by
the TWDT.

However, using the method esp_task_wdt_add, one have the possibility to monitor one or more application tasks.
It is written in the documentation that each task that is monitored have to feed the WDT so that it is not triggered.

Could you please explain me how does it work ? Are there more than one counter in the WatchDog timer in order to
monitor each task ? I don't understand how it can work with 5 tasks for example.

Thank you for your explainations,

best regards,

Thomas TRUILHE

a2800276
Posts: 78
Joined: Sat Jan 23, 2016 1:59 pm

Re: Esp32s3 : Question about the Task Watch Dog Timer

Postby a2800276 » Fri Jun 23, 2023 12:10 pm

Here's the documentation for `esp_task_wdt_add`. You need to call `esp_task_wdt_reset` periodically from each of the (in your case) 5 registered tasks.


And here's a sample project from the IDF that demonstrates usage of the necessary code.

ESP_Sprite
Posts: 9607
Joined: Thu Nov 26, 2015 4:08 am

Re: Esp32s3 : Question about the Task Watch Dog Timer

Postby ESP_Sprite » Sat Jun 24, 2023 2:23 am

FWIW, the way it works (a bit simpified) is that esp_task_wdt_reset only sets a flag that for this round, the associated task did reset their watchdog. There's a timer that periodically calls a routine that checks if all the registered tasks have done so, and if that's the case it feeds the hardware watchdog. Failure of one or more tasks to feed the watchdog, or some sort of corruption that makes the timer routine not work, will cause the hardware watchdog to trigger.

ThomasESP32
Posts: 214
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32s3 : Question about the Task Watch Dog Timer

Postby ThomasESP32 » Sat Jun 24, 2023 5:41 am

Good morning,

good, I know understand how the watchdog for the tasks works thank you.
So, I have registered my tasks and call the reset function periodically in each one.

Now, if the watchdog is triggered, I would like to reset the chip.
I have seen that for each stage of the watchdogs (TWD), I can define 3 actions (Interrupt, CPU reset, Core reset).
I would like to use the Core reset when the Watchdog is triggered (At the moment only printf are done).
Do you know how to configure the different stages of the watchdogs and how to tell that I would like to do a Core Reset ???
I don't see anything concerning the configuration.

Please, the same question concerning the Interrupt Watchdog. I see that it is activated by default,
but I don't see how to configure the action when the interrupt watchdog is triggered.

Best regards,

Thomas TRUILHE

ThomasESP32
Posts: 214
Joined: Thu Jul 14, 2022 5:15 am

Re: Esp32s3 : Question about the Task Watch Dog Timer

Postby ThomasESP32 » Mon Jun 26, 2023 8:17 am

Good morning,
I have finally found the registers concerning the WDT.

I am trying to asks/display the configuration registers of WDT0 which is ON when the
firmware is running (Used to monitor the tasks) and I get the following results :

=====> TIMG_T0_USE_XTAL : 0.
=====> TIMG_T0_ALARM_EN : 0.
=====> TIMG_T0_DIVIDER : 1.
=====> TIMG_T0_AUTORELOAD : 1.
=====> TIMG_T0_INCREASE : 1.
=====> TIMG_T0_EN : 0.

In order to display these values, I am using the lines :

RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_USE_XTAL);
ESP_LOGI(TAG, "=====> TIMG_T0_USE_XTAL : %u.", RegValue);
RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_ALARM_EN);
ESP_LOGI(TAG, "=====> TIMG_T0_ALARM_EN : %u.", RegValue);
RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_DIVIDER);
ESP_LOGI(TAG, "=====> TIMG_T0_DIVIDER : %u.", RegValue);
RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_AUTORELOAD);
ESP_LOGI(TAG, "=====> TIMG_T0_AUTORELOAD : %u.", RegValue);
RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_INCREASE);
ESP_LOGI(TAG, "=====> TIMG_T0_INCREASE : %u.", RegValue);
RegValue = REG_GET_FIELD(TIMG_T0CONFIG_REG(0), TIMG_T0_EN);
ESP_LOGI(TAG, "=====> TIMG_T0_EN : %u.", RegValue);

>This is strange because the tasks watchdog is running but I get the value : TIMG_T0_EN : 0. (Enabled = 0).
Do you have any idea ?
Maybe this is due to the usage of the line TIMG_T0CONFIG_REG(0) => Do you know what I have to use a (0) at the end in order
to access the configuration register ?

Best regards,

Who is online

Users browsing this forum: Majestic-12 [Bot] and 79 guests