下载
![](https://oss-datasheet.aipcba.com/html/3F731F5A0012068185F67850C5FCC191/bg1.png)
Freescale Semiconductor
Application Note
Document Number: AN3496
Rev.0, 07/2007
Contents
© Freescale Semiconductor, Inc., 2007. All rights reserved.
In the HCS08 family of microcontrollers, interrupts
provide a way to save the current CPU status and
registers, execute an interrupt service routine (ISR), and
then restore the CPU status so processing resumes where
it left off before the interrupt.
Before an ISR is completed, the global interrupt mask
(I bit) in the condition code register (CCR) is set to mask
further interrupts. This mechanism ensures that the ISR
is not interrupted during execution. However, the
disadvantage of this mechanism is that a high-priority
interrupt cannot interrupt a low-priority ISR execution.
This document provides a solution to yield a prioritized
interrupt mechanism in software. This benefits anyone
who wants more powerful and flexible applications
without a task-based real-time operation system (RTOS)
support.
1 Non-Nested Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Interrupt Stack Frame . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Inhibiting Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Nested Interrupt Mechanism . . . . . . . . . . . . . . . . . . . . . . 4
2.1 Requirements Of Nested Interrupts. . . . . . . . . . . . . 5
2.2 Software Nested Interrupt Scheduler . . . . . . . . . . . 5
2.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Port User Program with the Scheduler . . . . . . . . . . . . . 11
3.1 Variable and Macro Definitions . . . . . . . . . . . . . . . 11
3.2 Interrupt Service Routine Definitions . . . . . . . . . . . 12
3.3 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1 Flash Memory Consumption . . . . . . . . . . . . . . . . . 13
4.2 RAM Consumption . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 Time Consumption . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Miscellaneous Topics . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1 Use ISR Not Supporting Scheduler. . . . . . . . . . . . 15
5.2 Use Scheduler in the Main Loop . . . . . . . . . . . . . . 15
Appendix AScheduler Code Lists . . . . . . . . . . . . . . . . . . . . . 16
A Software Approach to Using
Nested Interrupts in HCS08
by: Kenny Ji
Asia & Pacific Operation Microcontroller Division