EasyManua.ls Logo

ST ST7 - The Interrupt Mechanism and How to Use It; Interrupt Handling

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
29/317
2 - How does a typical microcontroller work?
quences in applications where the microcontroller must keep in control, like in automotive ap-
plications or in security systems.
Various solutions have been imagined to prevent such situations. The most popular is the
watchdog timer. This is a timer that is set for a certain durationat power up. The program must
reset it to its start value periodically; failing to do so, the timer will overflow and this event gen-
erates a hardware reset. This restores the system to the state it was at power up.
To use the watchdog timer properly, the program must reset it at the appropriate time, in a pe-
riodic manner. To do this efficiently requires some care. A word of advice is given on this sub-
ject in a later chapter.
2.5 THE INTERRUPT MECHANISM AND HOW TO USE IT
A microcontroller is a programmed computer that executes a single string of statements
known as «the program». Therefore, it apparently cannot perform more than one task at a
time.
However, most if not all applications require a single microcontroller to handle many things at
once. Usually, for cost-effectiveness and simplicity, the designer of a microcontroller-based
system tries to pack as many functions as possible in a single chip.
The answers to this problem are based both on hardware and on software. The hardware ap-
proach is called «interrupt handling» and the software approach is called «multitaskin.
2.5.1 Interrupt handling
An interrupt, in computer terminology, is a mechanism that allows the currently executing pro-
gram to be interrupted, as the name implies, when an external event occurs. The computer
then starts to execute a specially-written piece of code that is intended to process the in-
coming event. Once this processing is finished, the main program resumes exactly where it
was interrupted. Nothing else happens to this program except that its execution is delayed by
the time it took to process the interrupt-triggered code.

Table of Contents

Related product manuals