Hello all,
I am currently using FreeRTOS kernel on a STM32f4, and I have the following problem:
-
I have three tasks and when they are of the same priority as TimerTask (configTIMER_TASK_PRIORITY), everything works correctly.
-
If I use a task of higher priority than TimerTask nothing starts, and when I increase the priority of TimerTask (same priority as the higher one), only the higher task works.
-
If I leave the same priority for all tasks, but that of TimerTask and higher, no task starts (it is as if it takes the cpu without freeing it).
NOTE: Knowing that the higher priority task and indeed blocks a good time to allow the activity of lower priority tasks.
My code is Here (working version):
#define configUSE_PREEMPTION 1
#define configUSE_TIMERS 1
#define configUSE_TIME_SLICING 1
#define configTIMER_TASK_PRIORITY 2
void TaskBlue(void *pvParameters) {
while (1) {
blue_on();
vTaskDelay(pdMS_TO_TICKS(5000));
}
}
void TaskGreen(void *pvParameters) {
while (1) {
green_on();
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void TaskRed(void *pvParameters) {
while (1) {
red_on();
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void main_loop(void) {
clock_Init ();
timer_init();
SystemCoreClockUpdate();
if(SystemCoreClock != 168000000u){
error();
return;
}
SysTick_Config(SystemCoreClock / configTICK_RATE_HZ);
NVIC_SetPriority(SysTick_IRQn, configKERNEL_INTERRUPT_PRIORITY);
BaseType_t resultBlue = xTaskCreate(TaskBlue, "Blue LED", configMINIMAL_STACK_SIZE*2, NULL, 2, NULL);
BaseType_t resultGreen = xTaskCreate(TaskGreen, "Green LED", configMINIMAL_STACK_SIZE*2, NULL, 2, NULL);
BaseType_t resultRed = xTaskCreate(TaskRed, "Red LED", configMINIMAL_STACK_SIZE*2, NULL, 2, NULL);
if (resultBlue != pdPASS || resultGreen != pdPASS || resultRed != pdPASS) {
error();
return;
}
vTaskStartScheduler();
error();
for (;;);
}
Thank you by advance!