Quality RTOS & Embedded Software

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




Loading

Software timers (V8.2.3): xTimerStop seems to do nothing

Posted by philpem on December 2, 2016

Hi,

I have a program which uses a one-shot software timer as part of a password-protection scheme. Locked functions can be accessed for a few minutes after a valid password is entered, and using a locked function extends the lockout.

To put it another way: * Entering the password starts the timer * Every locked function resets it * "Logging out" stops the timer * Locked functions check whether the timer is running before they allow access. If it isn't, a request is made for the password.

This looks good on paper, but I'm having issues with software timers.

If I allow the software timer to time out (wait a few minutes), things work as expected: xTimerIsTimerActive() reports that the timer is running until it times out, then it reports that it has stopped.

If I call xTimerStop against the timer, then xTimerIsTimerActive reports the timer has not stopped.

I was under the impression (from the API documentation) that xTimerStop returned the timer to the Dormant state, and xTimerIsActive returned pdFALSE in this case?

In fact, if I wait a little longer, the timer continues to run until it times out, and the callback function is called.

So it seems as though xTimerStop isn't actually doing anything, at least in FreeRTOS 8.2.3. I've also downloaded 9.0.0 and it seems to be the same.

I've looked at the code, and prvProcessReceivedCommands seems to expect "something else" to remove the timer from the active timers list and/or stop it (as evidenced by the comment "The timer has already been removed from the active list. There is nothing to do here."), but I can't find anything else which removes the timer from the active list.

Thanks, Phil.


Software timers (V8.2.3): xTimerStop seems to do nothing

Posted by rtel on December 2, 2016

This scenario is tested in the timerdemo.c source file, and is passing. The timer is removed from the list a few lines above the comment you refer to:

if( xMessage.xMessageID >= ( BaseType_t ) 0 )
{
     /* The messages uses the xTimerParameters member to work on a
     software timer. */
     pxTimer = xMessage.u.xTimerParameters.pxTimer;

     if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) 
== pdFALSE )
     {
         /* The timer is in a list, remove it. */
         ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
     }

Is the priority of the timer service task lower than the priority of the task that is stopping the timer and then checking to see if the timer is still running? If so then the task that stops the timer will not have executed yet - hence the timer will still be running.


[ 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