My device program is intermittently getting locked up while in Deep Sleep, running the ulp function (below). I have the watchdog timer running in the main portion of my program and initialize it at the very beginning of the main loop. I add the standard syntax at the beginning of my ulp function and it compiles, but does not seem to be working. Is there another way to call a watchdog timer in ulp? Is there a different watchdog for ulp? This is the last bit of code I need to get our product out. Your help is appreciated.
********************************************************************************************
void ulp_start(uint32_t dutyMeter) {
esp_task_wdt_add(NULL); //add current thread to WDT watch
ulpStarted = 1; //program flag to determine if ulp is started
//// Slow memory initialization
//memset(RTC_SLOW_MEM, 0, 8192); //this sets all RTC memory to Zero
// if LED is connected to GPIO2 (specify by +14)
const gpio_num_t MeterPWMPin = GPIO_NUM_2;
const int MeterPWMBit = RTCIO_GPIO2_CHANNEL + 14;
// GPIOx initialization (set to output and initial value is 0)
rtc_gpio_init(MeterPWMPin);
rtc_gpio_set_direction(MeterPWMPin, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_set_level(MeterPWMPin, 0);
// Define ULP program
const ulp_insn_t ulp_prog[] = {
M_LABEL(1),
I_WR_REG(RTC_GPIO_OUT_REG, MeterPWMBit, MeterPWMBit, 1), // on
I_DELAY(dutyMeter),
I_WR_REG(RTC_GPIO_OUT_REG, MeterPWMBit, MeterPWMBit, 0), // off
I_DELAY(900), //factor of meter max duty cycle
M_BX(1),
};
// Run ULP program
size_t size = sizeof(ulp_prog) / sizeof(ulp_insn_t);
ulp_process_macros_and_load(0, ulp_prog, &size);
ulp_run(0);
esp_task_wdt_reset(); //reset WDT for new 3s count
}
Watchdog Timer in ULP
Re: Watchdog Timer in ULP
- Writing to ULP program memory while it's running can cause all kinds of issues. Make sure it's not still running before reinitialisation. Note that it's in the RTC domain which survives most resets, so even a esp_restart() after an OTA update could leave the old ULP program from the previous firmware running, for example. See this thread for more: https://esp32.com/viewtopic.php?f=13&t=9298#p110755
- The task watchdog will only ensure that a FreeRTOS task isn't blocked for too long. This is unrelated to the ULP, and will not be active in deep sleep.
- If you want a WDT in deep sleep, use the RTC WDT. You will need to ensure it is configured not to pause in sleep (there's a bit in its configuration register for this), which might require digging into IDF to find where this is set before entering deep sleep.
- The task watchdog will only ensure that a FreeRTOS task isn't blocked for too long. This is unrelated to the ULP, and will not be active in deep sleep.
- If you want a WDT in deep sleep, use the RTC WDT. You will need to ensure it is configured not to pause in sleep (there's a bit in its configuration register for this), which might require digging into IDF to find where this is set before entering deep sleep.
-
- Posts: 11
- Joined: Fri Apr 08, 2022 6:02 pm
Re: Watchdog Timer in ULP
Thank you for the feedback! I will look into that and post my results.
Who is online
Users browsing this forum: No registered users and 39 guests