Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Infinite loop When the scheduler active the lowest priority task

Posted by pauldufay on March 17, 2015

Hi,

I have a problem with the scheduler and i am new with freeRTOS. It have a good fonctionnement with all other task but when it comes to active the lowest priority task, when the task is finish, it restarts at the beginning of this task infinitly. It loop.

Can you explain me why?

Thank for any explication

Creation of My Lowest Task :

xTaskCreate( TaskLog,"TaskLog", configMINIMALSTACKSIZE,NULL ,tskIDLE_PRIORITY + 2, NULL );

Definition of My Task:

static void TaskLog (void * pvParameters) {

TickType_t 			xLastWakeTime;
const TickType_t 	xFrequency = 80;
FRESULT 			rc;
xLastWakeTime = xTaskGetTickCount();

for(;;)
{

vTaskDelayUntil( &xLastWakeTime, xFrequency );

f_mount(0, &fatfsLOG);
rc = f_open(&filLOG, FileNameSdCard, FA_WRITE | FA_OPEN_ALWAYS);    
                         WriteSdCardFile(RTC_DateStructure,RTC_TimeStructure,sec_frac,GPSData_Wk,IMU1Data_Wk,IMU2Data_Wk);
DisableInterrupts();

f_close(&filLOG);
f_mount(0, NULL);
WriteBauderatefile();

DisableInterrupts();

}

}


Infinite loop When the scheduler active the lowest priority task

Posted by rtel on March 17, 2015

I'm not sure I follow the description of the problem. Your task is implemented as an infinite loop - as would be normal. When it gets to the bottom of the for(;;) loop I would expect it to go back to the top of the for(;;) loop - are you saying instead of doing that it is going right back to the top of the function - so executing the call to xTaskGetTickCount() again?

By the way - you should not disable and enable interrupts directly, but use taskENTERCRITICAL() and taskEXITCRITICAL() instead.

Regards.


Infinite loop When the scheduler active the lowest priority task

Posted by pauldufay on March 17, 2015

No, sorry i think my explication was not very complete. I have 6 task. and when the scheduler run, it active task 1 ( the highest priority task ) , after task 2, task 3 ,.... and when it active the last and lowest priority task ( My TaskLog joined before ), the scheduler don't active the task 1 when this task is finish. It just active always the last task.

Thanks for explication.


Infinite loop When the scheduler active the lowest priority task

Posted by rtel on March 17, 2015

So TaskLog() never starts at all - is that right?

If so, what happens? Does the system crash, or does the higher priority task just continue running?

If the higher priority task continues running, does it ever enter the Blocked state? If it does not enter the Blocked state then it will starve the lower priority tasks of processing time.

Regards.


Infinite loop When the scheduler active the lowest priority task

Posted by pauldufay on March 18, 2015

No, TaskLog is the lowest priority task, and when the scheduler reach it (it is the last task call in my program ), TaskLog repeat itself infinity. The scheduler never pause this task for reaching the highest or an other task.

When i done a eTaskGetState() for all task; All task are ready to execute.

i have 4 task with priority of 3 , 1 task with priority of 2 and TaskLog priority of 2.

I just want that the scheduler authorize the highest task just after the lowest task is finish.

Is my Problem more clear?

Thanks for explication

ps: I use Eclipse and OpenOCD like debugger.


Infinite loop When the scheduler active the lowest priority task

Posted by pauldufay on March 18, 2015
I found that, the task loops infinitly just when i put the f_open function in. Now when i erase f_open, the task finish but the scheduler do nothing and the program look like it don't crash, but probably scheduler crash and no others task is reach.

static void TaskLog (void * pvParameters) {

TickType_t 			xLastWakeTime;
const TickType_t 	xFrequency = 80;
FRESULT 			rc;
xLastWakeTime = xTaskGetTickCount();

eTaskState EtatGPS, EtatCal, EtatLog;

for(;;)
{

vTaskDelayUntil( &xLastWakeTime, xFrequency );
WriteSdCardFile(RTC_DateStructure,RTC_TimeStructure,sec_frac,GPSData_Wk,IMU1Data_Wk,IMU2Data_Wk);

EtatGPS = eTaskGetState( TaskGps );
EtatCal = eTaskGetState( TaskCal );
EtatLog = eTaskGetState( TaskLog );

}

}


Infinite loop When the scheduler active the lowest priority task

Posted by pauldufay on March 18, 2015

I found the solution. The Stack size was to small. Now : configMINIMALSTACKSIZE * 15

Thanks for your time Have a Good Day


Infinite loop When the scheduler active the lowest priority task

Posted by rtel on March 18, 2015

Maybe a helpful link:

http://www.freertos.org/FAQHelp.html

It mentions how to monitor the stack and check for stack overflows.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner