I was trying to learn ESP-IDF with FreeRTOS, and when I am using a code from the data sheet with very minimal changes (REF code : Documentation page:53 and 54. The Board is restarting.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void vTask1(void* pvParameters){
const char* pcTaskName = "Task 1 is running \n";
for(;;){
printf(pcTaskName);
vTaskDelay(1000/ portTICK_PERIOD_MS);
}
}
void vTask2(void* pvParameters){
const char* pcTaskName = "Task 2 is running \n\n";
for(;;){
printf(pcTaskName);
vTaskDelay(1000/ portTICK_PERIOD_MS);
}
}
void app_main(void){
xTaskCreate( vTask1,
"TASK 1",
1000,
NULL,
1,
NULL );
xTaskCreate( vTask2, "TASK 2", 1000, NULL, 1, NULL);
vTaskStartScheduler();
while(true);
}
Now when I removed the vTaskStartScheduler()
and the infinity while loop. the program is not restarting but the out put is not as expected .
The Code used
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void vTask1(void* pvParameters){
const char* pcTaskName = "Task 1 is running \n";
for(;;){
printf(pcTaskName);
vTaskDelay(1000/ portTICK_PERIOD_MS);
}
}
void vTask2(void* pvParameters){
const char* pcTaskName = "Task 2 is running \n\n";
for(;;){
printf(pcTaskName);
vTaskDelay(1000/ portTICK_PERIOD_MS);
}
}
void app_main(void){
xTaskCreate( vTask1,
"TASK 1",
1000,
NULL,
1,
NULL );
xTaskCreate( vTask2, "TASK 2", 1000, NULL, 1, NULL);
}
The obtained out put is
- I want to learn why the first code as shown in the data sheet didn't work .
- Why the second code is not behaving like Task1->Task2 - Task1->Task2 ...