⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
3 posts / 0 new
Last post
Eric Scammell
Offline
Last seen:2 years 12 months ago
加入:2017-03-15 13:28
GPIO Edge Interrupts

I'm attempting to use the GPIO interrupts to detect the rising and falling edges on some switches, but I'm having trouble with some interrupts firing as soon as I enable them using GPIO_EnableIRQ.
For example, I've got a rising-edge interrupt on a pin which is initially low. There's also a falling-edge interrupt on the same pin which does not immediately fire.
Similarly the falling-edge interrupt fires on a pin which is initially high.

Is there any way to suppress this immediate interrupt so that my edge-triggered interrupts only fire on edges?

Device:
MT_dialog
Offline
Last seen:3 months 1 day ago
Staff
加入:2015-06-08 11:34
Hi Eric,

Hi Eric,

I am not sure i understand the question, i dont see any firing up of the interrupts as soon as i invoke the GPIO_EnableIRQ() unless the pin is at the state that fires the interrupt (if you set the interrupt to be triggered at the opposite state that triggers at your current setup, the interrupt will still be triggered ?), you can try to manually reset the interrupt (GPIO_ResetIRQ() before enabling the corresponding interrupt) and check if that solves what you are experiencing. Regarding the Edge interrupts, in the 580 the GPIO interrupts are level triggered and not edge triggered, but you will be able to detect the transition from high to low or the opposite by changing the polarity of the interrupt as soon as it triggers, something like the below snippet:

void irq0_interrupt_cb(void)
{
if (GPIO_GetIRQInputLevel(GPIO0_IRQn)==GPIO_IRQ_INPUT_LEVEL_LOW)
{
GPIO_SetActive(LED_PORT, LED_PIN);
GPIO_SetIRQInputLevel(GPIO0_IRQn,GPIO_IRQ_INPUT_LEVEL_HIGH);
}
else
{
GPIO_SetInactive(LED_PORT, LED_PIN);
GPIO_SetIRQInputLevel(GPIO0_IRQn,GPIO_IRQ_INPUT_LEVEL_LOW);
}
}

也有关you are facing please have a look at the additional parameters that the GPIO_EnableIRQ, the debounce for example or the release_wait, perhaps there the line that drives the interrupt has spikes that trigger the interrupt.

Thanks MT_dialog

Eric Scammell
Offline
Last seen:2 years 12 months ago
加入:2017-03-15 13:28
Thank you, I seem to have

Thank you, I seem to have misunderstood the API. I had the impression that the interrupts could be configured for edge detection, if that's not the case then the errors I was experiencing make sense.