Interrupts and the SFR Page Stack
When an interrupt occurs, the current SFRPAGE is pushed onto an SFR page stack to preserve the current context of SFRPAGE.
Upon execution of the RETI instruction, the SFRPAGE register is automatically restored to the SFR page that was in use prior to the
interrupt. The stack is five elements deep to accomodate interrupts of different priority levels pre-empting lower priority interrupts. Firm-
ware can read any element of the SFR page stack by setting the SFRPGIDX field in the SFRPGCN register and reading the
SFRSTACK register.
Table 3.1. SFR Page Stack Access
SFRPGIDX Value
SFRSTACK Contains
0
Value of the first/top byte of the stack
1
Value of the second byte of the stack
2
Value of the third byte of the stack
3
Value of the fourth byte of the stack
4
Value of the fifth/bottom byte of the stack
Notes:
1. The top of the stack is the current SFRPAGE setting, and can also be directly accessed via the SFRPAGE register.
000
001
010
011
100
SFRPAGE
SFRSTACK
Interrupt
Logic
SFRPGEN
SFR Page
Stack
SFRPGIDX
Figure 3.1. SFR Page Stack Block Diagram
When an interrupt occurs, hardware performs the following operations:
1. The value (if any) in the SFRPGIDX = 011b location is pushed to the SFRPAGE = 100b location.
2. The value (if any) in the SFRPGIDX = 010b location is pushed to the SFRPAGE = 011b location.
3. The value (if any) in the SFRPGIDX = 001b location is pushed to the SFRPAGE = 010b location.
4. The current SFRPAGE value is pushed to the SFRPGIDX = 001b location in the stack.
5. SFRPAGE is set to the page associated with the flag that generated the interrupt.
On a return from interrupt, hardware performs the following operations:
1. The SFR page stack is popped to the SFRPAGE register. This restores the SFR page context prior to the interrupt, without soft-
ware intervention.
2. The value in the SFRPGIDX = 010b location of the stack is placed in the SFRPGIDX = 001b location.
3. The value in the SFRPGIDX = 011b location of the stack is placed in the SFRPGIDX = 010b location.
4. The value in the SFRPGIDX = 100b location of the stack is placed in the SFRPGIDX = 011b location.
Automatic hardware switching of the SFR page upon interrupt entries and exits may be enabled or disabled using the SFRPGEN loca-
ted in SFRPGCN. Automatic SFR page switching is enabled after any reset.
EFM8UB3 Reference Manual
Special Function Registers
silabs.com
| Building a more connected world.
Rev. 0.2 | 29