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);
}
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 5,(IOCON_DIGMODE_EN | IOCON_MODE_INACT) );/* Configure GPIO pin as input */
Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 5);/* Enable PININT clock */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PININT);/* Reset the PININT block */
Chip_SYSCTL_PeriphReset(RESET_PININT);/* Configure interrupt channel for the GPIO pin in INMUX block */
Chip_INMUX_PinIntSel(0, 0, 5);/* Configure channel interrupt as edge sensitive and falling edge interrupt */
Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT, PININTCH(0));
Chip_PININT_SetPinModeEdge(LPC_GPIO_PIN_INT, PININTCH(0)); //working as high edge interrupt for npn sensor
Chip_PININT_EnableIntHigh(LPC_GPIO_PIN_INT, PININTCH(0)); //int high edge/* Enable interrupt in the NVIC */
NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
NVIC_EnableIRQ(PIN_INT0_IRQn);
Hello,
Thank you for your reply.
I am using the LPC1837FET100 on a custom PCB.
I have looked at the the examples hover I did not manage to get it to work.
Best regards,
Guido
Hi Guido,
I'm kind of new to LPC products and currently using the new LPCOpen that what I think you are as the API's are slightly different.
I am using LPCOpen_v2.05. Can you try using new version and the periph_pinint example?
I used my OM13076 (LPC18s37) board to test rising and falling with the SW2 on the board and it works fine.
Attached is my pinint.c with modifications to have both edges working to toggle blue LED.
Regards,
David
Hi
Could you let us know which LPC product you are using?
There with an example for GPIO group interrupt for LPC4357 product at LPCOpen software (Keil MCB4300 board).
Customer could refer that example as well.
Wish it helps.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------