I was stumbling with an IRQ problem. So, as usual, reduced the problem to it's minimum.
So, given this code snippet why does the interrupt fire when the mbed is rebooted or powered on?
#include "mbed.h"
Serial pc(USBTX, USBRX);
InterruptIn test(p29);
DigitalOut myled(LED1);
DigitalOut led2(LED2);
void test_irq(void) {
printf("This should never be called\r\n");
led2 = 1;
}
int main() {
led2 = 0;
test.mode(PullDown);
test.rise(&test_irq);
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Given that nothing is connected to p29 (it's left floating), by setting PullDown and then adding an IRQ function, when the Mbed powers on, the pin irq routine is called once and only once.
Why is that? Given that I pulled it down before adding the IRQ vector, why does it fire when there is no rising edge on the pin?
Edit: I added a wire link from p29 to GND and the IRQ doesn't fire. So not sure where the spurious IRQ edge comes from in the example above. So I suppose I need to find out in my project why the external device doesn't take p29 low fast enough! Can't even spot it with the scope.
I was stumbling with an IRQ problem. So, as usual, reduced the problem to it's minimum.
So, given this code snippet why does the interrupt fire when the mbed is rebooted or powered on?
Given that nothing is connected to p29 (it's left floating), by setting PullDown and then adding an IRQ function, when the Mbed powers on, the pin irq routine is called once and only once.
Why is that? Given that I pulled it down before adding the IRQ vector, why does it fire when there is no rising edge on the pin?
Edit: I added a wire link from p29 to GND and the IRQ doesn't fire. So not sure where the spurious IRQ edge comes from in the example above. So I suppose I need to find out in my project why the external device doesn't take p29 low fast enough! Can't even spot it with the scope.