Quality RTOS & Embedded Software

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


timer issue

Posted by williamjsell on May 19, 2015

Target: LCP177x_8x RTOS version: 8.0.0 IDE: Rowley Crossworks for ARM

We have a debounce algorithm for a membrane switch, which relies on the setting and resetting of a timer in RTOS, based on button edge interrupts. This works great for a while, then the system appears to hang up after many repeated button presses. I traced the reason to this line in timers.c:

static void prvProcessReceivedCommands( void ) { DaemonTaskMessaget xMessage; Timert *pxTimer; BaseTypet xTimerListsWereSwitched, xResult; TickTypet xTimeNow;

while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL )

where suddenly I get a return status from the xTimerStopFromISR or xTimerStartFromISR indicating that the queue is full. I put a printf debug after the xQueueReceive and recreated the problem, and indeed this no longer was processing the messages from the timers. So the queue fills, the kernel seems quite happy, but we cannot navigate from the current screen as the buttons are frozen...any ideas what is stopping this from working?

timer issue

Posted by rtel on May 20, 2015

So if I understand correctly, the code you show is the loop which drains the timer command queue, the queue is full, but the timer task is no longer draining the queue.

If the timer task is not in the correct state then it could be an interrupt priority issue. Do you have configASSERT() defined? In later versions of FreeRTOS (not sure about V8.0.0) that will automatically catch interrupt priority mis-configurations.

I would recommend updating your FreeRTOS version anyway as V8 had an issue with the event groups "set bits from ISR" function http://www.freertos.org/History.txt.


timer issue

Posted by williamjsell on May 20, 2015

Yes, the problem is as you describe. Let me upgrade to the latest RTOS version first and see if this helps. How do you turn on the assertions (#define configASSERT in the FreeRTOSConfig.h file)?

timer issue

Posted by rtel on May 20, 2015

Yes - define it in FreeRTOSConfig.h, normal assert semantics. In its most basic form you can:

#define configASSERT( ( x ) ) if( ( x ) == 0 ){ 
portDISABLE_INTERRUPTS(); for(;;); }

to just bring the system to a stop on the offending line.



timer issue

Posted by williamjsell on May 20, 2015

OK, making some progress, the assert was very helpful. What I am seeing when the button is pressed is a trap in vPortValidateInterruptPriority(); the assert fails here: configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );

my confusion is the button is set to 0 priority, but the ucMaxSysCallPriority is set to 40. I thought (based on the doco at http://www.freertos.org/RTOS-Cortex-M3-M4.html and the LPC1788 UM, the max priority levels for an interrupt is 32. Still trying to understand how this all works...

timer issue

Posted by williamjsell on May 20, 2015

ok, problem solved and embarrassingly I had set all other system interrupt priorities correctly, but forgot the GPIO irq. Just required this line:


where the configGPIOINTERRUPTPRIORITY is greater than the configMAXSYSCALLINTERRUPT_PRIORITY value...

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists