Watchdog keeps timing out

blippy
Posts: 17
Joined: Tue Jun 25, 2019 7:36 am

Watchdog keeps timing out

Postby blippy » Tue Jun 25, 2019 8:00 am

Everything "works", I get the responses I'm expecting, but I keep getting a watchdog timeout, and it's bugging me. I'm running out of ideas. Here's what's being reported:

Code: Select all

E (33283) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (33283) task_wdt:  - IDLE1 (CPU 1)
E (33283) task_wdt: Tasks currently running:
E (33283) task_wdt: CPU 0: esp_timer
E (33283) task_wdt: CPU 1: vWhite

I'm trying to execute a function every 125us (effectively 8kHz). I think this is too fined-grained for RTOS for a delay, so I need another mechanism. So what I do is create a call-back that sets "hit" to true every 125us:

Code: Select all

volatile int8_t hit;
static void timcb(void* arg)
{
        hit = 1;
}
and set it up withinin app_main():

Code: Select all

    const esp_timer_create_args_t timargs = {
            .callback = &timcb,
            .name = "marksperiodic"
    };
    esp_timer_handle_t every;
    esp_timer_create(&timargs, &every);
    esp_timer_start_periodic(every, 125);
I have a task which checks to see if hit is 1, and responds accordingly:

Code: Select all

void vWhite(void* param)
{
        int idx =0;
        for(;;) {
                taskYIELD();
                esp_task_wdt_reset();
                if(!hit) continue;
                hit = 0;
                dac_output_voltage(DAC_CHANNEL_1, track_raw[idx++]);
                if(idx>= track_raw_len) idx = 0;
        }
}
I decided to pin the task to CPU1, and added a watchdog:

Code: Select all

    TaskHandle_t hnd1 = NULL;
    esp_task_wdt_init(3, false);
    esp_task_wdt_add(xTaskGetIdleTaskHandleForCPU(1));
    xTaskCreatePinnedToCore(vWhite, "vWhite", 10000, (void*) 1, configMAX_PRIORITIES/2, &hnd1, 1);
I've tried it without a watchdog, with a watchdog, yielding from the task, not yielding from the task, etc.. I still can't stop the watchdog being triggered. I'm baffled, It seems that there's just no way the watchdog isn't being fed. Any ideas?

The complete code is https://gist.github.com/blippy/c13cab82 ... 6bbf0835fa

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

Re: Watchdog keeps timing out

Postby ESP_Sprite » Tue Jun 25, 2019 8:09 am

Well, for one, you're probably better off either putting your code in the timer callback, or using a semaphore to signal your task to continue instead of polling a variable. If any, the taskYIELD may not do way you want: it relinquishes control to the highest-priority non-blocking task, but if that's the task that called taskYIELD in the first place (very likely in a pre-emptive setup like ESP-IDF uses), the task will happily keep on running.

Who is online

Users browsing this forum: No registered users and 152 guests