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.

Using input (RST/NMI/SBWTDIO) of MSP430G2230

Other Parts Discussed in Thread: MSP430G2230

Hello everyone!

I am using the input (RST/NMI/SBWTDIO) of MSP430G2230 for controlling an LED. I set up the microcontroller to suffer interruption in NMI falling edge and light the LED. But I would like to know when the user releases the button, in order to clear LED.
In short, The LED should be lit when the button (RST / NMI / SBWTDIO) is pressed and enquando the button is pressed the the LED stays on. The LED will only go out when the button is released

Best regard

Leonardo!

  • NMI is edge triggered IRQ only, you can not read its state anywhere.

    Using NMI for anything is to much of a hassle as it's hard to use debugger at the same time.
    Maybe OK if it's something you add in the last part of programming that  that does not need much fixing up for final code.

    That said you can toggle the edge and wait for another IRQ,
    Though there is a chance due to bounce noise from a button that you miss the edge switching in time as there may be a rapid number of edges and due to software overhead you get out of sync and you have to press again.

    hardware debouce will help: http://www.ganssle.com/images/debouncerrc.jpg (R1,R2 = 10-30K and C= 2-10nF)

    IRQ

    xor.w   #0x3300+WDTNMIES,&WDTCTL  ; xor edge, also turn password 0x69 in to 0x5a
    bit.w   #WDTNMIES,&WDTCTL         ; Is falling edge selected?
    jnz noled
    led on
    reti
    noled led off
    reti

**Attention** This is a public forum