Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists