Quality RTOS & Embedded Software

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


Timer set

Posted by joe_her on July 14, 2015

I have a simple timer call back which just decrements a variable:

int timerx; // the callback function: void vTimerCb1Sec( TimerHandle_t pxTimer ) { timerx--; }

Now I need to set timerx:

void set1SecTimer(uint32_t val ) { xTimerStop(xTimers1Sec,10); timerx = val; xTimerStart(xTimers1Sec,10);


Is it safe to do it without stop and start like this?

void set1SecTimer(uint32_t val ) { timerx = val; }

Thanks, Johanan

Timer set

Posted by davedoors on July 14, 2015

Probably not safe just to set timerx, but it can be done in a critical section no need to stop then start the timer.

taskENTERCRITICAL(); timerx = val; taskEXITCRITICAL();

Timer set

Posted by joe_her on July 14, 2015

Thanks Dave.

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

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

Latest News

Meet Richard Barry and learn what's new in the FreeRTOS project at Embedded World 2019

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

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.


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



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