Hi All,
Just for future reference in this thread and to avoid complexity confusion for other readers, I thought i'd also post how you achieve the same thing using the mbed libraries:
// example of using InterruptIn
// - connect p6 to 3.3v to trigger an interrupt
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led4(LED4);
InterruptIn button(p6);
void button_handler() {
led1 = !led1;
}
int main(void) {
button.rise(&button_handler);
while (1) {
led4 = !led4;
wait(0.25);
}
}
The full details at on the InterruptIn handbook page.
You could also mix and match; use the DigitalOut of the mbed library to control the LEDs, and the register-poking to setup and handle the interrupt. All depends on what you are trying to achieve.
Glad you got it working!
Simon
Hello,
I have a question about interrupts. I have a pushbutton connected at p6
and set it so that it lights up led1 whenever I press it. The program compiles fine since the status led (LED4)
is on. However the interrupt routine doesn’t work. Can somebody point what am I missing.