Quality RTOS & Embedded Software

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


Loading

xTimerStart hangs the application

Posted by freertos99 on 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 PERIODMS ( 1000UL / portTICKRATE_MS)

static TimerHandlet xApp[10] = {NULL}; void timerstart(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( TimerHandlet xTimer ) { int i=0; i = ( int ) pvTimerGetTimerID( xTimer ); printf("Inside timer callbackrn"); timerstart(i); }

void inittimer(void) { int i; //create timers for(i=1;i<6;i++) { xApp[i] = xTimerCreate("AppTimer", (PERIODMS+ (100i)), pdFALSE, (void) i, TimerCallback); } //start timers for(i=1;i<6;i++) timer_start(i);

}

FreeRTOSConfig.h

define configUSE_TIMERS 1
define configTIMERTASKPRIORITY ( 3 )
define configTIMERQUEUELENGTH 10
define configTIMERTASKSTACKDEPTH ( configMINIMALSTACK_SIZE )

~~~


xTimerStart hangs the application

Posted by richard_damon on January 22, 2019

One possible issue is that timer callbacks aren't supposed to block, and depending on how printf is implemented, it might not be suitable for use in a timer callback.

If you use a debugger to stop the system, (and have configASSERT defined) does it show you caught on an assert, and if so which one?


xTimerStart hangs the application

Posted by freertos99 on January 23, 2019

Thanks for pointer. You are right.. the problem was due to printf's in callback routine. Now I can see the timer getting started. Maybe we can document that timer callbacks should not be blocked (as a NOTE) or maybe this is basic thing which I'm not aware of :( Thank you.


xTimerStart hangs the application

Posted by xz8987f on January 23, 2019

See https://www.freertos.org/RTOS-software-timer.html: "Important information on writing timer callback functions Timer callback functions execute in the context of the timer service task. It is therefore essential that timer callback functions never attempt to block. For example, a timer callback function must not call vTaskDelay(), vTaskDelayUntil(), or specify a non zero block time when accessing a queue or a semaphore. "


xTimerStart hangs the application

Posted by freertos99 on January 24, 2019

thank you


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


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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

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