AN2109 Freescale Semiconductor / Motorola, AN2109 Datasheet - Page 31

no-image

AN2109

Manufacturer Part Number
AN2109
Description
MPC555 Interrupts
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
7.3.2 Example 2: ISR Using Assembly Language Only
Summary: This example illustrates a SCI interrupt initialization and an interrupt exception routine done
entirely in assembler.
Operation: To keep these examples short, the SCI only receives characters. For the SCI receive inter-
rupt, this data is required to operate:
The base_pointer is used as a pointer to the beginning of the buffer for receiving the serial data.
Buffer_size is the size of the buffer. For example, if the buffer has a size of 100 byte, Buffer_size=100.
Based on these two values, a buffer is defined, which resides in memory from base_pointer to
base_pointer+Buffer_size-1.
Current_index is an internal variable which is the index of the next location for the next character.
Current_index must be initialized by the CPU before the first interrupt.
The example assumes that the SCI resides on a unique level, therefore SIVEC directly reports the SCI
as interrupt source. The SCI in this example uses level 5.
As receive and transmit of the SCI use the same interrupt level, there must be a decision, whether a
receive or a transmit interrupt must be serviced.
“actual_buffer” can be observed in a debugger watch window collecting the received characters.
Stack Frame: The stack frame used is shown below. It is larger now, because of:
The “machine context”, (i.e., SRR0 and SRR1 is saved). This is recommended practice in order to allow
the processor to recover from additional exceptions during the interrupt routine.
Additional GPRs are saved. For this example, the only code that will executed is assembler code. By
inspecting it, we can identify all the registers needed during the interrupt routine and then save them on
the stack.
This stack frame is a more proper example than the bare minimal case in Example 1 because of being
able to recover from exceptions during the interrupt routine, see
Struct
Offset from SP
{ char* base_pointer;
} REC_Buf
Int Buffer_size;
int Current_index;
36
32
28
24
20
16
12
8
4
0
Freescale Semiconductor, Inc.
Table 19 Assembly Code Only Stack Frame
For More Information On This Product,
LR – IMPORTANT: Cannot save LR in prior stack frame
Placeholder for LR of function to be called
Back chain (old SP)
Rev. 0, 26 July 2001
MPC555 Interrupts
Go to: www.freescale.com
Register Saved
SRR1
SRR0
CR
R6
R5
R4
R3
Table
19.
MOTOROLA
31

Related parts for AN2109