![Infineon Technologies XC2200 User Manual Download Page 246](http://html1.mh-extra.com/html/infineon-technologies/xc2200/xc2200_user-manual_2055439246.webp)
XC2200 Derivatives
System Units (Vol. 1 of 2)
Interrupt and Trap Functions
User’s Manual
5-34
V2.1, 2008-08
ICU_X2K, V2.2
Context Switching
An interrupt service routine usually saves all the registers it uses on the stack and
restores them before returning. The more registers a routine uses, the more time is spent
saving and restoring. The XC2200 allows switching the complete bank of CPU registers
(GPRs) either automatically or with a single instruction, so the service routine executes
within its own separate context (see also
).
There are two ways to switch the context in the XC2200 core:
Switching Context of the Global Register Bank
changes the complete global register
bank of CPU registers (GPRs) by changing the Context Pointer with a single instruction,
so the service routine executes within its own separate context. The instruction “SCXT
CP, #New_Bank” pushes the contents of the context pointer (CP) on the system stack
and loads CP with the immediate value “New_Bank”; this in turn, selects a new register
bank. The service routine may now use its “own registers”. This register bank is
preserved when the service routine terminates, i.e. its contents are available on the next
call. Before returning (RETI), the previous CP is simply POPped from the system stack,
which returns the registers to the original global bank.
Resources used by the interrupting program, such as the DPPs, must eventually be
saved and restored.
Note: There are certain timing restrictions during context switching that are associated
with pipeline behavior.
Switching Context by changing the selected register bank
automatically updates
bitfield BANK to select one of the two local register banks or the current global register
bank, so the service routine may now use its “own registers” directly. This local register
bank is preserved when the service routine is terminated; thus, its contents are available
on the next call.
When switching to the global register bank, the service routine usually must also switch
the context of the global register bank to get a private set of GPRs, because the global
bank is likely to be used by several tasks.
For interrupt priority levels 15 … 12 the target register bank can be pre-selected and
then be switched automatically. The register bank selection registers BNKSELx provide
a 2-bit field for each possible arbitration priority level. The respective bitfield is then
copied to bitfield BANK in register PSW to select the register bank, as soon as the
respective interrupt request is accepted.
identifies the arbitration priority level assignment to the respective bitfields
within the four register bank selection registers.