RTOS embedded in the MSP430F148 microcontroller (2)
source: application Author: Li Qiang Zhang Junmo Chen Yao : 2010-09-12
2 interrupt stack structure design of
in uC/OS-II, task switching is divided into task switching and interrupt level switch. The task switching is achieved by soft interrupt instruction or rely on the processor executes instructions to complete the. Soft interrupt instruction will force some processor register save to the current task of the stack, and the implementation of the task scheduling. Its purpose is to make the stack structure is in the ready state task looks like just happened to break and will be stored in the same register stack. Such as MCS-5l and x86 chips have a similar command, but the problem in some single chip without soft interrupt instruction, and register according to the single chip and the use of the compiler differ greatly in different preservation breaks.
MSP430F148 no soft interrupt instruction, used by the IAR compiler in the event of interruption will not save all registers, but just to save a few to use in the interrupt register. All of these are not in conformity with the transplantation of uC/OS-II conditions. Our solution is based on the specific to their own definition of a interrupt structure, whether disruption or scheduling and initialization tasks stack or in task scheduling, are carried out in accordance with this structure. Price must be written on the interruption of the procedure of assembly code manually change, to comply with this interrupt structure.
is designed with a interrupt stack structure requirements, must first understand the use of singlechip perform what operations in the event of interruption, the preservation of the which registers to the stack and their sequence. When the MSP430 microcontroller interrupt occurred, only 2 basic operations, the SR (register) onto the stack to save, and then the fault occurs, the next instruction to execute PC value onto the stack save. Secondly, we must make clear that the use of C compiler compiled in C language interrupt program, for which the default operation. Through the compiler to use IAR V2.13 compiler, assembler for analysis, can be found, in addition to the 2 basic operations above, in the interrupt program beginning, also automatically saved R12~R15 four registers, the remaining R4~Rll eight registers kept off procedures used in the individual registers in, rather than save all. But in RTOS must save all registers, so that we can correctly save the task state. Through the above analysis, we define the interrupt stack structure of MSP430 when running uC/OS-II, as shown in figure 1.