Skip to main content

IAR Embedded Workbench for RISC-V 3.40

__preemptive

In this section:
Syntax

See Syntax for type attributes used on functions.

Description

When the __preemptive keyword is used on an interrupt function, the enter sequence saves some control and status registers (CSR) and enables global interrupts. This allows nested interrupts. The values will be automatically restored when the function exits.

These CSRs are saved:

  • For machine interrupts: mcause and mepc

  • For supervisor interrupts: scause and sepc

  • For user interrupts: ucause and uepc

If the device needs to save additional CSRs, use the #pragma preemptive directive.

Example
__preemptive __interrupt void myInterruptFunction(void);
See also

preemptive