Unlike Vanilla FreeRTOS, users of FreeRTOS in ESP-IDF must never callvTaskStartScheduler() and vTaskEndScheduler() . Instead, ESP-IDF starts FreeRTOS automatically.
You are likely getting the watchdog timer expired because of the extra call to vTaskStartScheduler which prevents Arduino framework to manage it.
is this a good way to make the led blink on different rates
#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu = 0 ;
#else
static const BaseType_t app_cpu = 1;
#endif
// Pins
static const int led_pin = 2;
//Our task blink a led
void toggleLed1(void * parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(500 / portTICK_PERIOD_MS );
digitalWrite(led_pin, LOW);
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
// homework to change the delay to another time
void toggleLed2(void * parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(200 / portTICK_PERIOD_MS );
digitalWrite(led_pin, LOW);
vTaskDelay(200 / portTICK_PERIOD_MS);
}
}
void setup() {
pinMode(led_pin, OUTPUT);
// Task to run forever
xTaskCreatePinnedToCore(
toggleLed1, // Function to be called
"ToggleLed", // name of the function
1024, // stack size
NULL, // parameter to pass to the function
1, // priority
NULL , // task handle
app_cpu
);
xTaskCreatePinnedToCore(
toggleLed2, // Function to be called
"ToggleLed2", // name of the function
1024, // stack size
NULL, // parameter to pass to the function
1, // priority
NULL , // task handle
app_cpu
);
}
void loop() {
}
This isn’t the ideal way to make the LED blink at different rates. Issue is that you have two tasks trying to control a single shared resource, which is the LED; this can lead to a race condition.
Since the purpose of this Forum is to provide support related to FreeRTOS and its libraries, and the question seems like homework, I can’t comment further on this, but there are lots of resources online that can help you with this.
it is not homework because im not at school or something but a self thaught developer who wants to learn more about rtos but wants to be sure he really understands things and do not learn bad things or ways
The challenge was to make a second task that blinks the same led.