This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interrupt on both rising and falling edges



Is it possible to program the MSP430 such that either rising or falling edge of an input will cause an interrupt?  Driving the signal into two input and inverting one is an alternative but I am wondering if there is a way to use only a single input.

Bob

 

  • Hi Bob,

    Many of the pins on an MSP430 can give you an interrupt on either rising or falling edges, your choice.  A single pin can be configured to detect either edge with the PxIES register (edge select).

    Some pins on the MSP430 can also be configured to give you an interrupt on both edges, but I don't think you were asking about that.

    Jeff

  • Jeff,

    Thanks for the reply.  Which pins allows detecting an interrupt on both edges?

    Bob

  • Timer pins (and port-mapping pins, which can be connected to a timer) can raise interrupts on both edges.  A 2-bit field in CCTLn configures the capture mode.  Either no capture, capture rising edges, capture falling edges, or capture both edges.

    To get behavior similar to a traditional interrupt-enabled pin, configure the timer for asynchronous capture (SCS=0) and don't trust the captured value (in CCRn).

    Jeff

  • Jeff Tenney said:
    To get behavior similar to a traditional interrupt-enabled pin, configure the timer for asynchronous capture (SCS=0) and don't trust the captured value (in CCRn).

    :) It's called 'downgrading'

    However, interrupts on both edges are possible fo rnormal port pins too. There's a simple logic: a raising edge cannto happen if the was no falling edge before. So if you trigger on the falling edge, you can switch to a trigger on the raising edge in the ISR and v.v.
    In theory, it's possible to miss an edge this way, but if you ar enot fast enough to handle the two interrupts, then you'r enot fast enough to handle the interrupts of a two-edged trigger too.

**Attention** This is a public forum