
93/317
5 - Peripherals
bled during the service of an interrupt. In this case, all interrupts are validated and the service
routine may be itself interrupted by a request having a lower priority than its own. If the service
routine must be interruptible only by certain requests and not others, the routine must first
clear the interrupt enable flags of all peripherals that are not allowed at that time, then clear the
global interrupt mask. It is wise to save the value of these flags before clearing them, if several
interrupts may interrupt each other and each selects a different set of allowed interrupt re-
quests.
05-nest
This core is perfectly well able to handle nested interrupt servicing, with a limited nesting
depth. However, care must be taken about two things:
The size of the stack. Each interrupt pushes five bytes on the stack, plus the interrupt service
routine may push some bytes to protect any data in memory that may be used globally.
The problem of atomicity as explained in Chapter 2. If an interruptible service routine handles
multi-byte data, it must take into account the possibility of being interrupted in the middle of a
data read or write with the risk of data incoherence.
The applications described in Chapters 9 and 10 illustrate several uses of interrupts, in con-
junction with various peripherals.
Main :bit I=0
A maskable
interrupt occurs
interrupt # j
interrupt # j
interrupt # k
Main :bit I=0
Here, the programmer
resets the I bit **
The I bit is set by hardware
Another maskable interrupt (nested interrupt) is
serviced, within the current one, whatever its priority
Without the intervention
of the programmer, bit I =0;
the interrupt # j can again
be interrupted
Nested interrupts
** Note: before resetting the I bit, you should clear the pending bit that started the current
interrupt, otherwise an endless recursive interrupt service call will be performed !
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...