freertos99 wrote on Tuesday, January 22, 2019:
Hi Experts,
I have an application run on freertosv10.1 which creates five timers using xTimerCreate() with different timeout periods. After expiry of each timer the callbacks print a message and again start the timer. Four timers are working perfectly but 5th timer calls the callback once after expiry and hangs after the start of the timer. I’ve run out of ideas on how to debug this issue. Can anyone please help ?
#define PERIOD_MS ( 1000UL / portTICK_RATE_MS)
static TimerHandle_t xApp[10] = {NULL};
void timer_start(int p)
{
switch(p)
{
case 1:
xTimerStart(xApp[1], 0);
break;
case 2:
xTimerStart(xApp[2], 0);
break;
case 3:
xTimerStart(xApp[3], 0);
break;
case 4:
xTimerStart(xApp[4], 0);
break;
case 5:
xTimerStart(xApp[5], 0);
break;
default:
break;
}
}
static void TimerCallback( TimerHandle_t xTimer )
{
int i=0;
i = ( int ) pvTimerGetTimerID( xTimer );
printf("Inside timer callback\r\n");
timer_start(i);
}
void init_timer(void)
{
int i;
//create timers
for(i=1;i<6;i++)
{
xApp[i] = xTimerCreate("AppTimer", (PERIOD_MS+ (100*i)), pdFALSE, (void*) i, TimerCallback);
}
//start timers
for(i=1;i<6;i++)
timer_start(i);
}
FreeRTOSConfig.h
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( 3 )
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )