xTaskResume STM32

stmiko wrote on Friday, June 18, 2010:


I using FreeRTOS for differents tasks and one of them calls vTaskSuspendAll() to suspend all real time activity. After performing the operation i want to reactivate the scheduler with xTaskResumeAll(). But the tasks don´t start to work. I have generated the TickHook ISR the check the scheduler and count up a variable in this function. This works fine but the tasks don´t work again after calling the resume order…
Does anybody know this problem?



davedoors wrote on Friday, June 18, 2010:

Can you post a small section of code where these calls are made? Maybe you are in a critical section when calling the functions?

If you post some code please use the codify text tags so the formatting does not get all screwy.

stmiko wrote on Friday, June 18, 2010:

static portTASK_FUNCTION( vMenuTask, pvParameters )
portTickType xLastPollTime;
	/* The parameters are not used. */
	( void ) pvParameters;
	xLastPollTime = xTaskGetTickCount();
		vTaskDelayUntil( &xLastPollTime, 1 / portTICK_RATE_MS ); //alle 1 ms
		if(uiTrigger ==1)
			Ack(C_BUSY); //SIPLUG in Messung
			Menu();		//Charakerter empfangen ?  -> verarbeiten
void  Menu(void)
//do something else...
switch (c) 
 /* Uhrzeit setzen */
     case 'u':                                	   
		Time.Weekday = status.datetime.Weekday;
		Time.Year = status.datetime.Year;
		Time.Month = status.datetime.Month;
		Time.Date = status.datetime.Date;
		Time.Hour = status.datetime.Hour;
		Time.Minute = status.datetime.Minute;
		Time.Second = status.datetime.Second;
		if(Parameter2(&Time,sizeof(Time))!=0) break;
		du[0] =	BCDToInt(Time.Weekday);
		du[1] =	BCDToInt16(Time.Year);
		du[2] =	BCDToInt(Time.Month);
		du[3] =	BCDToInt(Time.Date);
		du[4] =	BCDToInt(Time.Hour);
		du[5] =	BCDToInt(Time.Minute);
		du[6] =	BCDToInt(Time.Second);
		SetTime(du[4], du[5], du[6]);		//clock_calender.h
		SetDate(du[3], du[2], du[1]);
		if( !xTaskResumeAll() )
              TaskYIELD ();
//There are more switch cases...


rtel wrote on Friday, June 18, 2010:

The line:

if(Parameter2(&Time,sizeof(Time))!=0) break;

breaks out of the case statement while the scheduler is still suspended.  Calls to vTaskSuspendAll() can nest, so exactly the same number of calls to xTaskResumeAll() must be made as previous calls to vTaskSuspendAll() before the scheduler is resumed.  When your problem occurs inspect the value of uxSchedulerSuspended (in tasks.c) and you will probably find that it is not zero.


stmiko wrote on Friday, June 18, 2010:

Hello Richard,

I´ve changed the code according to your answer and know it works!