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.

MSP432P401R: Doubt about interruption input button

Part Number: MSP432P401R

I have been trying to detect when a signal goes from low to high (0 to 3.3 V) using the MSP432 button example, in the code below I am using P6.4 to detect this, the problem is that for some reason the program only triggers the interrupt (PORT6_IRQHandler) when the input signal goes from high to low, even thought I configured the resistor as pull down or pull up (neither of them allow me to detect when the signal goes from low to high). Does someone know's why?

Note: The ISR PORT6_IRQHandler turns on and off P1.0, the problem can be better observed in the image below where the input signal and the output pin where monitored.

/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>

int a = 0 ;
uint32_t status,status2;

int main(void)
{
    WDT_A_holdTimer();

    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P6, GPIO_PIN4);

    GPIO_clearInterruptFlag(GPIO_PORT_P6, GPIO_PIN4);
    GPIO_enableInterrupt(GPIO_PORT_P6, GPIO_PIN4);
    Interrupt_enableInterrupt(INT_PORT6);
    SysCtl_enableSRAMBankRetention(SYSCTL_SRAM_BANK6);
    Interrupt_enableMaster();

    while (1)
    {
        PCM_gotoLPM3();
    }
}

/* GPIO ISR */
void PORT6_IRQHandler(void)
{
    a++;
    status = GPIO_getEnabledInterruptStatus(GPIO_PORT_P6);
    GPIO_clearInterruptFlag(GPIO_PORT_P6, status);

    if(status == 16)
    {
        GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    }

}

Thanks

  • I think you're looking for something like

    GPIO_interruptEdgeSelect(GPIO_PORT_P6, GPIO_PIN4, GPIO_LOW_TO_HIGH_TRANSITION);

  • Hi Bruce, thanks for your reply, the code line works, but now I have another doubt, if I want to detect both (low to high and high to low) transitions what should I do?, in fact I implemented something that migth work but I do not think is the best way:

    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    int a = 0 ;
    uint32_t status,status2;
    
    int main(void)
    {
        WDT_A_holdTimer();
    
        GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    
        GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P6, GPIO_PIN4);
        GPIO_interruptEdgeSelect(GPIO_PORT_P6, GPIO_PIN4, GPIO_LOW_TO_HIGH_TRANSITION);
    
        GPIO_clearInterruptFlag(GPIO_PORT_P6, GPIO_PIN4);
        GPIO_enableInterrupt(GPIO_PORT_P6, GPIO_PIN4);
        Interrupt_enableInterrupt(INT_PORT6);
        SysCtl_enableSRAMBankRetention(SYSCTL_SRAM_BANK6);
        Interrupt_enableMaster();
    
        while (1)
        {
            PCM_gotoLPM3();
        }
    }
    
    /* GPIO ISR */
    void PORT6_IRQHandler(void)
    {
        status = GPIO_getEnabledInterruptStatus(GPIO_PORT_P6);
        GPIO_clearInterruptFlag(GPIO_PORT_P6, status);
    
        if(status == 16)
        {
            GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
        }
    // MODIFY EDGE SELECTION EVERY TIME
        if(a == 1)
        {
            GPIO_interruptEdgeSelect(GPIO_PORT_P6, GPIO_PIN4, GPIO_HIGH_TO_LOW_TRANSITION);
            a--;
        }
        else if(a == 0)
        {
            GPIO_interruptEdgeSelect(GPIO_PORT_P6, GPIO_PIN4, GPIO_LOW_TO_HIGH_TRANSITION);
            a++;
        }
    
    }

    Basically the code change the edge selection every time it detects an interruption from P6.4, is not another way? something like: 

     GPIO_interruptEdgeSelect(GPIO_PORT_P6, GPIO_PIN4, GPIO_BOTH_TRANSITION)


  • PxIES Registers only support high-to-low or low-to-high transitions.
    So, the way you implemented it is the only way it can be done.

  • The timer provides the ability to capture on both the rising and falling edges.

    Regards,
    Chris
  • Hi Chris,

    How would you implement a double edged I/O interrupt on P6 using a timer?
  • A timer in capture mode with CM=3 interrupts on both edges. I'm pretty sure the timer doesn't even have to be running (though I'm not sure I've ever tried it).

    For a physical button, the debounce time takes eons compared to the 5 clocks needed to reverse the IES bit. For a fast logic signal, capture is hard to beat.
  • Excellent point on using capture to generate the interrupt. I learned something new today. Thank you both.

**Attention** This is a public forum