Reading the value of an Interrupt Pin - MBED

Discussion in 'Embedded Systems and Microcontrollers' started by smock, Oct 21, 2011.

  1. smock

    Thread Starter New Member

    Jan 29, 2011

    I'm using the mbed microcontroller to program a few things. I am wondering if there is a way to read the value of an interrupt pin. The mbed Interrupt api only gives rise, fall, pullup, pulldown functions.

    I want my program to do something once the value on the interrupt pin goes low. I've set the pin to pulldown; however, how do i know what value that is.
    I don't want to use analog reading.

    Please help. Let me know if the question doesn't make sense

  2. t06afre

    AAC Fanatic!

    May 11, 2009
    The point of the interrupt pin is that the reaction is automated. If you have enabled for interrupt by some register(s) in your micro. Your micro will make a call to a fixed address. Here you will have placed some code to take care of the interrupt. This code is often referred to as Interrupt Service Routine or just ISR.
    The setup may vary. You should consult with your chip data sheet for the full details. Also as a friendly tip. Then you post in this forum always give such information as which micro you use, program language, and also schematics if you have. And of course your code. Posting this in your first time will give you much quicker response as we will ask for this information anyway
  3. Jon Wilder

    New Member

    Oct 25, 2011
    1 I/O pins are only ever in 1 of 2 possible states...1 and 0. Voltage levels above 2.1V are seen as logic 1 while voltage levels below 0.8V are seen as logic 0. Anything between 0.8V and 2.1V is considered the "noise" region.

    Typically a digital I/O pin that is set up as an input is either pulled high by a pull up resistor to the positive rail or pulled low by a pull down resistor to the ground rail. A switch wired between the pin and ground (pull up resistor configuration) or between the pin and the positive rail (pull down resistor configuration) will switch the pin between high and low states. Or you would have an external device with an output that pulls itself high/low driving the input pin.

    Digital I/O pins CANNOT read anything between 1 and 0. The region between 1 and 0 is in the analog realm.

    It sounds like what you need is an A/D converter (Analog to Digital converter, or ADC). A 10-bit ADC will take a rising/falling analog voltage and convert it into a 10-bit number. If your input voltage were between 0V and 5V, this number would get incremented/decremented by 1 for every 4.9mV change in input voltage (10 bits = 0-1024...5V / 1024 = 0.0049). A value of 0 from the ADC = 0V while a value of 1024 from the ADC = 5V, while everything between 0V and 5V will be the numbers 0-1024.
  4. BMorse

    Senior Member

    Sep 26, 2009
    "Pulldown" means to connect to ground via a resistor so the input is always going to be = 0, when it goes high then the ISR or interrupt routine will kick in...... so if you want it to respond to a low input (or 0) then you must set the initial state to high, or set the "Pullup" which is also done by connecting the input to Vcc via a resistor, so when the interrupt pin goes low, it will execute your code in the ISR..... you can "check" the state of an input with a multimeter or preferably a logic probe, if it reads 0 volts with a meter, then it is low, if the reading is close to VCC then it will be high.