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




Loading

FreeRTOS and traditional Watchdog Timer funct

Posted by joconnor37 on October 15, 2007
Could I broach the general subject of Watchdog Timer functionality when using FreeRTOS? I have completed a few modest real-time embedded systems projects with PIC 18Fxxxx MCUs over the last few years, always without a RTOS. I used the traditional "super loop", switch statements controlled by system states etc, etc. I always implemented the Watchdog Timer "liberally" at portions of the code.

I think to similarly liberally implement the Watchdog Timer still in FreeRTOS based projects - e.g. start the Watchdog Timer at start of a "potentially problematic" function such as a read/write on the I2C bus, so that in event of "failure" the program gets kicked out of the function by a Watchdog Timer reset. This resets PC back to first executable. Any thoughts on the ramifications of this when using FreeRTOS? Should the Watchdog Timer functionality be at the "task level" or remain at the "C function level", for example?

Kind Regards,

John O'Connor

RE: FreeRTOS and traditional Watchdog Timer funct

Posted by Richard on October 15, 2007
There are many different ways of using a watchdog timer in multi threaded applications. Some are quite complex, but unless you have a safety critical system I would suggest keeping things simple.

Unlike your previous single threaded applications your watchdog should look for hangs or errors within individual functions, and within the scheduler itself (not that the scheduler will ever go wrong of coarse :o).

One technique for this to have a watchdog variable within each task - this could be Boolean or a counter, I normally use the latter. For example, each task increments a counter at strategic places within the code, then a higher priority task (or a tick hook) periodically checks that all the counters within the system are still incrementing. If all counters are incrementing then the watchdog is kicked. If any counters unexpectedly retain their value for a period of time then it is assumed that the task is bad in some way, and the watchdog is stopped (or the system [or just the task] manually reset in software, the watchdog then being a back for a total failure). If a task finds an error in its function it simply stops incrementing its counter. If a task hangs, then the counter will stop automatically.

This mechanism is implemented in a basic way by the demo applications that come with each FreeRTOS.org port. Most of these implement a 'check' task, or 'check' hook function. This looks at all the other tasks to ensure they are running as expected. In this case though, rather than using a watchdog to fix an error, the check task simply outputs some signal (LED or LCD) to indicate that an error has been found.

You could use the idle task to check the other task are still running. This will then also ensure that the system is not overloaded. If the idle task ever gets starved out then the watchdog will fire.

Hope this helps.

Regards.

RE: FreeRTOS and traditional Watchdog Timer f

Posted by joconnor37 on October 15, 2007
Richard,

Many many thanks. Most helpful.

Kind Regards,

John O'Connor

RE: FreeRTOS and traditional Watchdog Timer funct

Posted by hanish maghu on April 18, 2013
Sir,
I have implemented watchdog timer driver using freertos on LPC1114 (NGX Base Board). I have used the problem statement above and a task whose priority is set to be idle task priority is monitoring 4 tasks where a counter is incremented. If the counter in any of the tasks stops then the idle task doesn't feed the watchdog timer and the system is reset by watchdog.We have implemented this as watchdog timer service as in the tasks which the developer thinks are very critical are the ones that feed idle task which further feeds watchdog timer counter.
We also wrote driver for watchdog and LCD also we measured interrupt latency of freertos which came out to be 1.73 micro seconds. link to the source code is as follows(it contains a readme.txt which basically describes the working of source code).

http://www.freertos.org/Interactive_Frames/Open_Frames.html?http://interactive.freertos.org/forums


[ 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