Quality RTOS & Embedded Software

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


[AVR]Best place to place Watchdog Timer Reset

Posted by zohair on July 23, 2007
I'm working on an ATMega32 and am trying to add a watchdog timer to the project.

I wanna know, what would be the best place to place the timer reset command. Since FreeRTOS uses multi-threading, I guess threads would continue to operate even if one of them hung up. I'm guessing I'll need to create a task to occasionally reset the Watchdog, but what should I set the priority to?

Since we're on the topic, how many tasks can I create on my system?

RE: [AVR]Best place to place Watchdog Timer Reset

Posted by Richard on July 23, 2007
The number of tasks you can create is dependent on the amount of RAM available and the size of the stack allocated to each task.

There is no simple answer to your watchdog question. It depends on how secure you want it to be. There are lots of papers available on watchdog design, it can get quite an academic subject. One approach is to have each task perform some form of self check and send a message to a watchdog task. The watchdog task then needs to run within a time window, and receive "I am ok" messages from all the other tasks before it kicks the dog.


RE: [AVR]Best place to place Watchdog Timer R

Posted by zohair on July 23, 2007
I'm guessing the number of tasks isn't simply (Available RAM / configMINIMAL_STACK_SIZE), right?

I was thinking of a simple watchdog and kick it at the lowest priority. That way if any higher priority task hangs, we get a reset. Any possible problems with this?

RE: [AVR]Best place to place Watchdog Timer R

Posted by David Hawks on July 23, 2007
That depends on the type of "hang". A higher priority task can "hang" by blocking on a resource that will not become available for whatever reason. The higher priority task will be left blocked and the lower priority watchdog reset task will be allowed to run. The watchdog will continue to operate even though a higher priority task is stuck. It is due to this kind of interaction that watchdog design can become an "academic subject" as Richard said.

Your simple watchdog will detect some failures, and maybe that is good enough for you. It is not fool-proof, however.

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

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

Latest News

Version 10.1.0 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