STMicroelectronics AN421 Stack Overflow Detection Application Note

This application note shows how to detect stack overflow by using the ST9 timer/watchdog.


STMicroelectronics AN421 Stack Overflow Detection Application Note - cover page
Brand
STMicroelectronics
Category
microcontrollers
Document type
Application Note
Language
English
Pages
11
File format
PDF
File size
87 KB
Published
07 August, 2012
Updated
28 September, 2023
Model
ST9
MD5 checksum
299B23FC100E0AF3241020D9CE0C2726

About this manual

This document describes a method to protect real-time applications running on ST9 microcontrollers from stack overflow errors. It details how to utilize the Timer/Watchdog peripheral to automatically generate a system reset if the application stack overwrites reserved memory locations containing specific watchdog restart values.

The note provides the theoretical principle behind the detection, including the required byte sequence (AAh, 55h) to restart the watchdog. It also includes specific software code examples for initializing the system stack in both the Register File and RAM space, as well as instructions for programming and restarting the Timer/Watchdog to ensure continuous monitoring.

What's inside

  • Introduction
  • Stack overflow detection principle
  • Summary of timer/watchdog features
  • Software description
  • Stack initialization
  • Timer/watchdog programming
  • Timer/Watchdog restart
  • Revision history

Specifications

Timer/Watchdog counter width16-bit down counter
Prescaler width8-bit prescaler
Time period range333 ns to 5.59 s
Maximum internal clock frequency12 MHz
Watchdog restart sequenceAAh, 55h

Frequently asked questions

How is the Timer/Watchdog restarted to prevent a system reset?

The byte sequence AAh, 55h must be written into the Timer Watchdog register Low.

What happens if the stack overwrites the reserved watchdog values?

The data is destroyed, and a system reset is generated on the next Timer Watchdog End Of Count.

Where can the system stack be located on ST9 devices?

The system stack may be located in the Register File or in data memory space.

Download PDF (87 KB)

More STMicroelectronics Manuals


View all STMicroelectronics manuals →