Hello,
Here is the code I am using to handle interrupts
GPIO_ConfigurePin(SW_CURSOR_PORT, SW_CURSOR_PIN, INPUT_PULLUP, PID_GPIO, true);
GPIO_RegisterCallback(GPIO0_IRQn, handle_event);
GPIO_EnableIRQ( SW_CURSOR_PORT, SW_CURSOR_PIN, GPIO0_IRQn, true, false, 3 );
void
handle_event(void)
{
printf_string("interrupt handler\n\r");
NVIC_ClearPendingIRQ(GPIO0_IRQn);
}
My interrupt handler gets called once if the pin is connected to ground but does NOT get called once it is disconnected from ground. So it is called on falling edges only -- how do I ensure it gets called on both rising and falling edges.
Thanks,
Saleem
PS: GPIO_* are functions defined in gpio.c included in the peripheral setup example.
As far as I know, you can use the following function to configure the external interrupt pin.
void wkupct_enable_irq(uint32_t sel_pins, uint32_t pol_pins, uint16_t events_num, uint16_t deb_time)
but you should first set high to low mode, and after that, set low to high mode manually. At least it works. Good luck.
You've configured the pin to respond to rising edge.
Try this : in the ISR callback, switch to the other edge (falling, rising) :
if ( GPIO_SetIRQInputLevel(GPIO0_IRQn) == GPIO_IRQ_INPUT_LEVEL_HIGH )
GPIO_SetIRQInputLevel(GPIO0_IRQn, GPIO_IRQ_INPUT_LEVEL_LOW);
else
GPIO_SetIRQInputLevel(GPIO0_IRQn, GPIO_IRQ_INPUT_LEVEL_HIGH);
Might work.... been having trouble with this myself.
Hi,
Can we configure the interrupt on pin 2.9?
I have used below code to configure the interrupt. But it is not working. Please verify and let me know the correct configuration for the port 2.9 pin.
GPIO_ConfigurePin(SWITCH3_PORT, SWITCH3_PIN, INPUT_PULLUP, PID_GPIO, false);
//configure pin & enable switch interrupts
GPIO_SetPinFunction(SWITCH3_PORT, SWITCH3_PIN, INPUT_PULLUP, PID_GPIO);
GPIO_EnableIRQ(SWITCH3_PORT, SWITCH3_PIN, GPIO0_IRQn, true, true, 3);
//GPIO_SetIRQInputLevel(GPIO0_IRQn, GPIO_IRQ_INPUT_LEVEL_LOW);
GPIO_RegisterCallback(GPIO0_IRQn, gpio_intr_callback );
//Callback function
void gpio_intr_callback(void)
{
GPIO_ResetIRQ(GPIO0_IRQn);
printf("\r\nKey press detected \r\n");
}
Please reply asap. Thank you.
Hi channaankiy25,
你可以检查文档- b - 051,因为我nformation about how to use the peripheral drivers of the da. Is your chip a QFN40 or QFN48 since port 2 is only available to those packages. From a quick look i guess that in RegisterCallback the irq that you want to enable is the GPIO2_IRQn since you want a pin from port 2.
Thanks MT_dialog