In this use case, the PMIC is configured for:
- all interrupt levels enabled
This will allow for interrupts from other modules being used.
This use case shows how to make an operation which consists of multiple instructions uninterruptible, i.e., into an atomic operation. This is often necessary if there is a risk that data can be accessed by interrupt handlers while other code is accessing it, and at least one of them modifies it.
Setup steps
Prerequisites
For the setup code of this use case to work, the following must be added to the project:
- Interrupts for the module requiring the PMIC module have to be enabled.
- An Interrupt Service Routine (ISR) for a given interrupt vector has to be defined, where the interrupt vectors available are defined by toolchain and listed in the subsection 'Interrupt Vector Summary' in the data sheet.
Example code
Add to application initialization:
Workflow
- call the PMIC driver's own init function to enable all interrupt levels:
- set global interrupt enable flag:
Usage steps
Example code
Add to application:
void atomic_operation(void)
{
}
Workflow
- allocate temporary storage for interrupt enable:
- clear global interrupt enable flag while saving its previous state:
- restore the previous state of global interrupt flag after operation: