65
32000D–04/2011
AVR32
sary state if other priority schemes are desired. It is the event source’s responsability to
ensure that their events are left pending until accepted by the CPU.
2.
When a request is accepted, the Status Register and Program Counter of the current
context is stored in the Return Status Register and Return Address Register corre-
sponding to the new context. Saving the Status Register ensures that the core is
returned to the previous execution mode when the current event handling is completed.
When exceptions occur, both the EM and GM bits are set, and the application may
manually enable nested exceptions if desired by clearing the appropriate bit. Each
exception handler has a dedicated handler address, and this address uniquely identi-
fies the exception source.
3.
The Mode bits are set correctly to reflect the priority of the accepted event, and the cor-
rect register file banks are selected. The address of the event handler, as shown in
The execution of the event routine then continues from the effective address calculated.
The rete instruction signals the end of the event. When encountered, the values in the Return
Status Register and Return Address Register corresponding to the event context are restored to
the Status Register and Program Counter. The restored Status Register contains information
allowing the core to resume operation in the previous execution mode. This concludes the event
handling.
8.2.2
Supervisor calls
The AVR32 instruction set provides a supervisor mode call instruction. The scall instruction is
designed so that privileged routines can be called from any context. This facilitates sharing of
code between different execution modes. The scall mechanism is designed so that a minimal
execution cycle overhead is experienced when performing supervisor routine calls from time-
critical event handlers.
The scall instruction behaves differently depending on which mode it is called from. The behav-
iour is detailed in the instruction set reference. In order to allow the scall routine to return to the
correct context, a return from supervisor call instruction, rets, is implemented.
8.2.3
Debug requests
The AVR32 architecture defines a dedicated debug mode. When a debug request is received by
the core, Debug mode is entered. Entry into Debug mode can be masked by the DM bit in the
status register. Upon entry into Debug mode, hardware sets the SR[D] bit and jumps to the
Debug Exception handler. By default, debug mode executes in the exception context, but with
dedicated Return Address Register and Return Status Register. These dedicated registers
remove the need for storing this data to the system stack, thereby improving debuggability. The
mode bits in the status register can freely be manipulated in Debug mode, to observe registers
in all contexts, while retaining full privileges.
Debug mode is exited by executing the retd instruction. This returns to the previous context.