I created the following example program, with 3 tasks. Task A runs on core 1 and task C runs on core 0. Now task A schedules a subtask B with a while loop.
In my understanding, this should cause a watchdog reset, but does not. However, when I remove task C from core 0, I do get a watchdog. What's the explanation for this?
Additional question:
Is it possible to have a subtask B that runs for example 10 seconds without feeding the watchdog or using vTaskDelay? (as it magically seem to do now)
The other task should still be executed on both cores. The parent task A would eventually force stop task B if it runs longer than 30 seconds.
Code: Select all
#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define CORE_0 0
#define CORE_1 1
#define TASK_SIZE 2048
static StackType_t StackA[TASK_SIZE] = {0};
static StackType_t StackB[TASK_SIZE] = {0};
static StackType_t StackC[TASK_SIZE] = {0};
static StaticTask_t TaskA;
static StaticTask_t TaskB;
static StaticTask_t TaskC;
TaskHandle_t taskHandle_A;
TaskHandle_t taskHandle_B;
TaskHandle_t taskHandle_C;
void taskARunnabe(void* args);
void taskBRunnabe(void* args);
void taskCRunnabe(void* args);
static int createdTaskB = 0;
void app_main(void)
{
printf("Hello world!\n");
printf("Starting Task C!\n");
taskHandle_C = xTaskCreateStaticPinnedToCore(taskCRunnabe, "TaskC", TASK_SIZE, NULL, 2, StackC, &TaskC, CORE_0);
if(!taskHandle_C)
{
printf("Starting Task C Failed!\n");
}
printf("Starting Task A!\n");
taskHandle_A = xTaskCreateStaticPinnedToCore(taskARunnabe, "TaskA", TASK_SIZE, NULL, 2, StackA, &TaskA, CORE_1);
if(!taskHandle_A)
{
printf("Starting Task A Failed!\n");
}
}
void taskCRunnabe(void* args)
{
while(1){
printf("TaskC\n");
vTaskDelay(10); // Avoid Task watchdog for Task C
};
printf("End Task C!\n");
}
void taskARunnabe(void* args)
{
//while(1){}; //Causes Task watchdog as expected
while(1){
if(createdTaskB == 0)
{
createdTaskB = 1;
printf("Starting Task B!\n");
taskHandle_B = xTaskCreateStaticPinnedToCore(taskBRunnabe, "TaskB", TASK_SIZE, NULL, 1, StackB, &TaskB, CORE_1);
if(!taskHandle_B)
{
printf("Starting Task B Failed!\n");
}
}
vTaskDelay(10); // Avoid Task watchdog for Task A
printf("TaskA\n");
}
printf("End Task A!\n");
}
void taskBRunnabe(void* args)
{
while(1){
printf("TaskB\n");
};
printf("End Task B!\n");
}