Page 1 of 1

Assigned Core0 Tasks Locks Up delay() with no WDT reset

Posted: Sun Jul 31, 2022 4:10 am
by ChuckBland
The code below is a function that is assigned to run on Core 0. Here are the setup lines.
  1. TaskHandle_t barTask;
  2.  
  3.   xTaskCreatePinnedToCore(barLoop,         //task function
  4.                                           "Bar Loop",    //task name
  5.                                           STACK_SIZE, //stack size in words (10K)
  6.                                           NULL,          //task input parameter
  7.                                           2,                //task priority
  8.                                          &barTask,     //task handle/scheduler
  9.                                          0);               //pin to core 0
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:
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.
I haven't been able to reset or feed the WDT in spite of using the commands you see.

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
  1. void barLoop(void *pvParameters)
  2.   {
  3.   while(true) //must remain captive in this routine and not be allowed to return
  4.     {
  5.     vTaskDelay(0);
  6.     //EVERY_N_MILLISECONDS(BAR_TIME)
  7.       //{
  8.       char buffer[40];
  9.       sprintf(buffer, "pattern: %d patternStep: %d", pattern, patternStep);
  10.       Serial.println(buffer);
  11.       switch(pattern)
  12.         {
  13.         case 0:
  14.           //alternate wide
  15.           //21
  16.           switch(patternStep)
  17.             {
  18.             case 0:
  19.             fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  20.            
  21.             case 4:
  22.             case 8:
  23.             case 12:
  24.               //yellow
  25.               fill_solid(barLEDS,      21, CHSV(HUE_YELLOW, 255, 255)); //0  to 20
  26.               fill_solid(&barLEDS[63], 21, CHSV(HUE_YELLOW, 255, 255)); //64 to 84
  27.               patternStep++;
  28.               vTaskDelay(0);
  29.               break;
  30.  
  31.             case 1:
  32.             case 5:
  33.             case 9:
  34.             case 13:
  35.               //black
  36.               fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  37.               patternStep++;
  38.               vTaskDelay(0);
  39.               break;
  40.  
  41.             case 2:
  42.             case 6:
  43.             case 10:
  44.             case 14:
  45.               //blue
  46.               fill_solid(barLEDS,      21, CHSV(HUE_BLUE, 255, 255)); //0  to 20
  47.               fill_solid(&barLEDS[63], 21, CHSV(HUE_BLUE, 255, 255)); //64 to 84
  48.               patternStep++;
  49.               vTaskDelay(0);
  50.               break;
  51.  
  52.             case 3:
  53.             case 7:
  54.             case 11:
  55.             case 15:
  56.               //black
  57.               fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  58.               patternStep++;
  59.               if (patternStep==16)
  60.                 {
  61.                 patternStep=0;
  62.                 pattern++;
  63.                 }
  64.               vTaskDelay(0);
  65.               break;
  66.             }//case patternStep
  67.           FastLED.show();
  68.  
  69.           break;
  70.  
  71.         case 1:
  72.           //red flash
  73.           if (patternStep % 2) fill_solid(barLEDS, BAR_LEDS, CHSV(HUE_RED, 255, BRIGHTNESS));
  74.           else fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  75.           FastLED.show();
  76.           patternStep++;
  77.           if (patternStep==16)
  78.             {
  79.             patternStep=0;
  80.             pattern++;
  81.             }
  82.           vTaskDelay(0);
  83.           break;
  84.  
  85.         case 2:
  86.           //alternate narrow
  87.           //42
  88.           switch(patternStep)
  89.             {
  90.             case 0:
  91.             fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  92.            
  93.             case 4:
  94.             case 8:
  95.             case 12:
  96.               //yellow
  97.               fill_solid(barLEDS, BAR_LEDS/2, CHSV(HUE_YELLOW, 255, 255));
  98.               patternStep++;
  99.               vTaskDelay(0);
  100.               break;
  101.  
  102.             case 1:
  103.             case 5:
  104.             case 9:
  105.             case 13:
  106.               //black
  107.               fill_solid(barLEDS, BAR_LEDS/2, CRGB::Black);
  108.               patternStep++;
  109.               vTaskDelay(0);
  110.               break;
  111.  
  112.             case 2:
  113.             case 6:
  114.             case 10:
  115.             case 14:
  116.               //blue
  117.               fill_solid(&barLEDS[42], BAR_LEDS/2, CHSV(HUE_BLUE, 255, 255));
  118.               patternStep++;
  119.               vTaskDelay(0);
  120.               break;
  121.  
  122.             case 3:
  123.             case 7:
  124.             case 11:
  125.             case 15:
  126.               //black
  127.               fill_solid(&barLEDS[42], BAR_LEDS/2, CRGB::Black);
  128.               patternStep++;
  129.               if (patternStep==16)
  130.                 {
  131.                 patternStep=0;
  132.                 pattern++;
  133.                 }
  134.               vTaskDelay(0);
  135.               break;
  136.             }//case patternStep
  137.            
  138.           FastLED.show();
  139.           break;
  140.  
  141.         case 3:
  142.           //blue flash
  143.           if (patternStep % 2) fill_solid(barLEDS, BAR_LEDS, CHSV(HUE_BLUE, 255, 255));
  144.           else fill_solid(barLEDS, BAR_LEDS, CRGB::Black);
  145.           FastLED.show();
  146.           patternStep++;
  147.           if (patternStep==16)
  148.             {
  149.             patternStep=0;
  150.             pattern++;
  151.             }
  152.           vTaskDelay(0);
  153.           break;
  154.         }//case pattern
  155.        
  156.         if (pattern > 3) pattern=0;
  157.         //delay(BAR_TIME);
  158.         vTaskDelay(0);
  159.         delayMillis(BAR_TIME);
  160.       //}//EVERY_N
  161.     }//while(true)
  162.   }//barLoop

Re: Assigned Core0 Tasks Locks Up delay() with no WDT reset

Posted: Sun Jul 31, 2022 7:54 pm
by ChuckBland
Fixed (one of the rare times you CAN fix stupid)

It is supposed to be delay(uint32_t), not delay(uint8_t) !!!!!!!

I must have lost ten hours because of that.

Please, enjoy a laugh at my expense.

Chuck