70
SAM4CP [DATASHEET]
43051E–ATPL–08/14
12.4.2.8 Programming Hints for the Synchronization Primitives
ISO/IEC C cannot directly generate the exclusive access instructions. CMSIS provides intrinsic functions for generation
of these instructions:
The actual exclusive access instruction generated depends on the data type of the pointer passed to the intrinsic
function. For example, the following C code generates the required LDREXB operation:
__ldrex((volatile char *) 0xFF);
12.4.3 Exception Model
This section describes the exception model.
12.4.3.1 Exception States
Each exception is in one of the following states:
Inactive
The exception is not active and not pending.
Pending
The exception is waiting to be serviced by the processor.
An interrupt request from a peripheral or from software can change the state of the corresponding interrupt to pending.
Active
An exception is being serviced by the processor but has not completed.
An exception handler can interrupt the execution of another exception handler. In this case, both exceptions are in the
active state.
Active and Pending
The exception is being serviced by the processor and there is a pending exception from the same source.
12.4.3.2 Exception Types
The exception types are:
Reset
Reset is invoked on power up or a warm reset. The exception model treats reset as a special form of exception. When
reset is asserted, the operation of the processor stops, potentially at any point in an instruction. When reset is
deasserted, execution restarts from the address provided by the reset entry in the vector table. Execution restarts as
privileged execution in Thread mode.
Non Maskable Interrupt (NMI)
A non maskable interrupt (NMI) can be signalled by a peripheral or triggered by software. This is the highest priority
exception other than reset. It is permanently enabled and has a fixed priority of -2.
Table 12-8.
CMSIS Functions for Exclusive Access Instructions
Instruction
CMSIS Function
LDREX
uint32_t __LDREXW (uint32_t *addr)
LDREXH
uint16_t __LDREXH (uint16_t *addr)
LDREXB
uint8_t __LDREXB (uint8_t *addr)
STREX
uint32_t __STREXW (uint32_t value, uint32_t *addr)
STREXH
uint32_t __STREXH (uint16_t value, uint16_t *addr)
STREXB
uint32_t __STREXB (uint8_t value, uint8_t *addr)
CLREX
void __CLREX (void)