Hey guys, I have deleted the post that I had here as I have narrowed down my problem somewhat.
I am going to deal with just one problem for the minute.
Essentially, the problem I am having is I am getting an interrupt when I shouldnt be.
In the code below, I am using a digitalinout pin and outputting a small sequence at which point I change the pin to an input and enable the interrupts.
Now, physically i have this pin connected to ground through a resistor and I also have the pin internally set to PullDown mode. But I get a rising edge interrupt somehow when I shouldnt be getting any. As the code below executes, I only appear to be getting rising edge interrupts as only led3 is toggling and not led4. I'd say falling edge triggers are still occurring but they are happening when the interrupts are set to NULL. Any ideas as to what the cause could be?
Thanks.
#include "mbed.h"
#pragma once
#define PINGPIN p22
DigitalInOut PingPin(PINGPIN);
InterruptIn Pinterrupt(PINGPIN);
DigitalOut led3(LED3); //these LEDs are used to indicate when an interrupt occurs.
DigitalOut led4(LED4);
void start_timing();
void set_time();
void set_interrupts()
{
Pinterrupt.fall(start_timing);
Pinterrupt.rise(set_time);
}
void disable_interrupts()
{
Pinterrupt.fall(NULL);
Pinterrupt.rise(NULL);
}
void start_timing()
{
led3 = !led3;
}
void set_time()
{
led4 = !led4;
}
int main() {
led3 = led4 = 0;
for(;;)
{
wait(1);
disable_interrupts();
PingPin.mode(PullDown);
Pinterrupt.mode(PullDown);
PingPin.output(); //set pingpin as output
PingPin = 0;
PingPin = 0; //output initiation sequence of 0 1 0 to the rangefinder
wait_us(2);
PingPin = 1;
wait_us(5);
PingPin = 0;
//PingPin.input(); //set as input
set_interrupts();
}
}
Hey guys, I have deleted the post that I had here as I have narrowed down my problem somewhat.
I am going to deal with just one problem for the minute.
Essentially, the problem I am having is I am getting an interrupt when I shouldnt be.
In the code below, I am using a digitalinout pin and outputting a small sequence at which point I change the pin to an input and enable the interrupts.
Now, physically i have this pin connected to ground through a resistor and I also have the pin internally set to PullDown mode. But I get a rising edge interrupt somehow when I shouldnt be getting any. As the code below executes, I only appear to be getting rising edge interrupts as only led3 is toggling and not led4. I'd say falling edge triggers are still occurring but they are happening when the interrupts are set to NULL. Any ideas as to what the cause could be?
Thanks.