AnsweredAssumed Answered

Gpio pin interrupt

Question asked by gvisser on Aug 19, 2016
Latest reply on Sep 14, 2016 by David E Seymour

Hello,

 

I am have a problem with receiving interrupts from the gpio pins.

The problem is that I never seem to receive an interrupt.

I can read the pin an have confirmed that it does change however I do not get an interrupt.

 

Can someone please advice me what i should do to get the interrupts on the rising and falling edge.

 

ResetISR()
{
    Chip_SCU_PinMuxSet( 6, 5, (SCU_MODE_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0) );
    Chip_SCU_PinMuxSet( 1,14, (SCU_MODE_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0) );
}

 

int main(void)
{
    static const uint32_t        c_controllerPort = 3;
    static const uint8_t        c_controllerPin = 4;
    static const uint32_t        c_responderPort = 1;
    static const uint8_t        c_responderPin = 7;
    bool controllerPin = 0;
    bool responderPin = 0;
    Board_Init();
    Chip_Clock_Enable(CLK_MX_GPIO);
    Chip_GPIO_Init(LPC_GPIO_PORT);
    Chip_GPIO_WriteDirBit(LPC_GPIO_PORT, c_controllerPort, c_controllerPin, false);
    Chip_GPIO_WriteDirBit(LPC_GPIO_PORT, c_responderPort, c_responderPin, false);
    Chip_GPIO_IntCmd(LPC_GPIO_PIN_INT, c_controllerPort, c_controllerPin, GPIOPININT_RISING_EDGE);
    Chip_GPIO_IntCmd(LPC_GPIO_PIN_INT, c_controllerPort, c_controllerPin, GPIOPININT_FALLING_EDGE);
    Chip_GPIO_IntCmd(LPC_GPIO_PIN_INT, c_responderPort, c_responderPin, GPIOPININT_RISING_EDGE);
    Chip_GPIO_IntCmd(LPC_GPIO_PIN_INT, c_responderPort, c_responderPin, GPIOPININT_FALLING_EDGE);
    Chip_SCU_GPIOIntPinSel(0, c_controllerPort, c_controllerPin);
    Chip_SCU_GPIOIntPinSel(1, c_responderPort, c_responderPin);
    NVIC_SetPriority(PIN_INT0_IRQn, 1);
    NVIC_SetPriority(PIN_INT1_IRQn, 2);
    NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
    NVIC_ClearPendingIRQ(PIN_INT1_IRQn);
    NVIC_EnableIRQ(PIN_INT0_IRQn);
    NVIC_EnableIRQ(PIN_INT1_IRQn);
    while(true)
    {
        if(controllerPin != Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, c_controllerPort, c_controllerPin))
        {
            controllerPin ^= 1;
        }
        if(responderPin != Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, c_responderPort, c_responderPin))
        {
            responderPin ^= 1;
        }
    }
}

extern "C" void GPIO0_IRQHandler(void)
{
    while(true);
    Chip_GPIO_IntClear(LPC_GPIO_PIN_INT, CUartOverGpio::c_controllerPort, CUartOverGpio::c_controllerPin);
    NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
}

extern "C" void GPIO1_IRQHandler(void)
{
    while(true);
    Chip_GPIO_IntClear(LPC_GPIO_PIN_INT, CUartOverGpio::c_responderPort, CUartOverGpio::c_responderPin);
    NVIC_ClearPendingIRQ(PIN_INT1_IRQn);
}

Outcomes