Closed majenkotech closed 5 years ago
Test code:
void __USER_ISR blink() {
static bool onoff = false;
onoff = !onoff;
digitalWrite(PIN_LED1, onoff);
clearIntFlag(_CORE_SOFTWARE_0_IRQ);
}
void setup() {
pinMode(PIN_LED1, OUTPUT);
setIntVector(_CORE_SOFTWARE_0_VECTOR, blink);
setIntPriority(_CORE_SOFTWARE_0_VECTOR, 4, 0);
clearIntFlag(_CORE_SOFTWARE_0_IRQ);
setIntEnable(_CORE_SOFTWARE_0_IRQ);
}
void loop() {
delay(1000);
setIntFlag(_CORE_SOFTWARE_0_IRQ);
}
Very nice!
This allows the triggering of an interrupt by software (simply setting the interrupt flag). This is especially useful if you want to make use of the two software interrupts SW0 and SW1.
The code is a direct copy-and-paste of
clearIntFlag()
withifs->clr
changed toifs->set
.