Core Module¶
Note
Features¶
Delaying execution¶
CORE_Delay
blocks execution on the core for N milliseconds.
The following code lets a LED toggle every 100ms so it flashes with a 5Hz frequency.
while (true) {
toggle_led();
CORE_Delay(100);
}
-
void CORE_Delay(uint32_t ms)¶
Blocks execution of a specific number of milliseconds.
- Parameters
ms – Milliseconds to wait
Resetting the core¶
CORE_Reset
issues a core reset which resets all peripherals and lets execution start over.
The following code causes a software reset when the reset button was pressed
if (reset_button_down())
CORE_Reset();
-
void CORE_Reset(void)¶
Resets the current CPU core.
Interrupt handling¶
Some code needs to run as fast as possible, without interrupts interfering with it. In these cases, disabling interrupts for that short duration is the best way. The following code prevents interrupts from occuring while it’s run. They will instead be executed as soon as the critical code has finished.
CORE_DisableInterrupts();
{
critical_function();
}
CORE_EnableInterrupts();
// Pending interrupts will be executed here
-
void CORE_DisableInterrupts(void)¶
Disables interrupt controller.
-
void CORE_EnableInterrupts(void)¶
Enables interrupt controller.
If interrupts that occured during this time should be ignored alltogether, the following code can be used.
CORE_DisableInterrupts();
{
critical_function();
}
CORE_ClearPendingInterrupts();
CORE_EnableInterrupts();
// No interrupts will be executed here
-
void CORE_ClearPendingInterrupts(void)¶
Clears all currently pending interrupts.