Quality RTOS & Embedded Software

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




Loading

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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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