Assigned Core0 Tasks Locks Up delay() with no WDT reset
Posted: Sun Jul 31, 2022 4:10 am
The code below is a function that is assigned to run on Core 0. Here are the setup lines.
At the bottom of the function you will see various lines that are commented. When I use the delay() function with a length as low as 1 and as long as 250, delay() never returns. I can put test code around this to verify. The WDT timer never fires. The code on CORE1 continues to run with no issues and delay() works just fine on core1. There is no need for WDT intervention
If I use any of the other techniques you see, I get this error every 7 seconds:
If I comment out off the various timing and resets, the code runs like lightning. It is controlling a string of LEDs and creates a blur that should look more like the lights on an ambulance. Thus I am certain the code in general is working.
I could sure use another few sets of eyes. Can anyone see what I'm doing wrong?
Chuck Bland
- TaskHandle_t barTask;
- xTaskCreatePinnedToCore(barLoop, //task function
- "Bar Loop", //task name
- STACK_SIZE, //stack size in words (10K)
- NULL, //task input parameter
- 2, //task priority
- &barTask, //task handle/scheduler
- 0); //pin to core 0
If I use any of the other techniques you see, I get this error every 7 seconds:
I haven't been able to reset or feed the WDT in spite of using the commands you see.20:38:58.465 -> E (14181) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
20:38:58.465 -> E (14181) task_wdt: - IDLE0 (CPU 0)
20:38:58.465 -> E (14181) task_wdt: Tasks currently running:
20:38:58.465 -> E (14181) task_wdt: CPU 0: Bar Loop
20:38:58.465 -> E (14181) task_wdt: CPU 1: IDLE1
20:38:58.465 -> E (14181) task_wdt: Aborting.
If I comment out off the various timing and resets, the code runs like lightning. It is controlling a string of LEDs and creates a blur that should look more like the lights on an ambulance. Thus I am certain the code in general is working.
I could sure use another few sets of eyes. Can anyone see what I'm doing wrong?
Chuck Bland
- void barLoop(void *pvParameters)
- {
- while(true) //must remain captive in this routine and not be allowed to return
- {
- vTaskDelay(0);
- //EVERY_N_MILLISECONDS(BAR_TIME)
- //{
- char buffer[40];
- sprintf(buffer, "pattern: %d patternStep: %d", pattern, patternStep);
- Serial.println(buffer);
- switch(pattern)
- {
- case 0:
- //alternate wide
- //21
- switch(patternStep)
- {
- case 0:
- fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- case 4:
- case 8:
- case 12:
- //yellow
- fill_solid(barLEDS, 21, CHSV(HUE_YELLOW, 255, 255)); //0 to 20
- fill_solid(&barLEDS[63], 21, CHSV(HUE_YELLOW, 255, 255)); //64 to 84
- patternStep++;
- vTaskDelay(0);
- break;
- case 1:
- case 5:
- case 9:
- case 13:
- //black
- fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- patternStep++;
- vTaskDelay(0);
- break;
- case 2:
- case 6:
- case 10:
- case 14:
- //blue
- fill_solid(barLEDS, 21, CHSV(HUE_BLUE, 255, 255)); //0 to 20
- fill_solid(&barLEDS[63], 21, CHSV(HUE_BLUE, 255, 255)); //64 to 84
- patternStep++;
- vTaskDelay(0);
- break;
- case 3:
- case 7:
- case 11:
- case 15:
- //black
- fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- patternStep++;
- if (patternStep==16)
- {
- patternStep=0;
- pattern++;
- }
- vTaskDelay(0);
- break;
- }//case patternStep
- FastLED.show();
- break;
- case 1:
- //red flash
- if (patternStep % 2) fill_solid(barLEDS, BAR_LEDS, CHSV(HUE_RED, 255, BRIGHTNESS));
- else fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- FastLED.show();
- patternStep++;
- if (patternStep==16)
- {
- patternStep=0;
- pattern++;
- }
- vTaskDelay(0);
- break;
- case 2:
- //alternate narrow
- //42
- switch(patternStep)
- {
- case 0:
- fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- case 4:
- case 8:
- case 12:
- //yellow
- fill_solid(barLEDS, BAR_LEDS/2, CHSV(HUE_YELLOW, 255, 255));
- patternStep++;
- vTaskDelay(0);
- break;
- case 1:
- case 5:
- case 9:
- case 13:
- //black
- fill_solid(barLEDS, BAR_LEDS/2, CRGB::Black);
- patternStep++;
- vTaskDelay(0);
- break;
- case 2:
- case 6:
- case 10:
- case 14:
- //blue
- fill_solid(&barLEDS[42], BAR_LEDS/2, CHSV(HUE_BLUE, 255, 255));
- patternStep++;
- vTaskDelay(0);
- break;
- case 3:
- case 7:
- case 11:
- case 15:
- //black
- fill_solid(&barLEDS[42], BAR_LEDS/2, CRGB::Black);
- patternStep++;
- if (patternStep==16)
- {
- patternStep=0;
- pattern++;
- }
- vTaskDelay(0);
- break;
- }//case patternStep
- FastLED.show();
- break;
- case 3:
- //blue flash
- if (patternStep % 2) fill_solid(barLEDS, BAR_LEDS, CHSV(HUE_BLUE, 255, 255));
- else fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
- FastLED.show();
- patternStep++;
- if (patternStep==16)
- {
- patternStep=0;
- pattern++;
- }
- vTaskDelay(0);
- break;
- }//case pattern
- if (pattern > 3) pattern=0;
- //delay(BAR_TIME);
- vTaskDelay(0);
- delayMillis(BAR_TIME);
- //}//EVERY_N
- }//while(true)
- }//barLoop