GPIO interrupt on rising edge only

Discussions relating to the XK-EVK-XU316
alex4d1
Member++
Posts: 21
Joined: Mon May 13, 2024 11:38 pm

GPIO interrupt on rising edge only

Post by alex4d1 »

Hello,

I'm developing an RTOS application that triggers on a GPIO interrupt. I'm working with a custom board which is based on the XCORE.AI Explorer Board.

My application follows this basic example:
https://github.com/xmos/xcore_iot/blob/ ... pio_ctrl.c

I enable the GPIO port, set the callback and enable the interrupt. The ISR then notifies my main loop. Just like in the example above.

The problem I am having is that the interrupt triggers on both rising and falling edge. I want it to trigger only on the rising edge.

I had a look at the GPIO RTOS driver and it should only trigger on rising edge (assuming the GPIO is 0 during configuration):
rtos_gpio.c, line 147-149

Code: Select all

value = port_peek(p);
port_set_trigger_in_not_equal(p, value);
triggerable_enable_trigger(p);
Am I missing something here? Any help would be greatly appreciated.

(PS: Simply checking the GPIO state in the ISR is one way to do this, but I'd like to prevent the ISR calls on falling edge altogether)

Thanks
Alex
User avatar
upav
Verified
Junior Member
Posts: 4
Joined: Wed May 22, 2024 3:30 pm

Post by upav »

Hey Alex,

I'm not an rtos expert, but I've used lib_xcore api you have in your snippet. The way I think it works:

get the current state of the port (let's say 0) -> set trigger for non-0
so this sets the trigger for the rising edge, which is desirable, great

when the port is finally triggered on the rising edge, I assume it somehow runs the same snippet again which will essentially:
get the current state of the port (which is now 1) -> set trigger from non-1
which sets the trigger for the falling edge

Can't really help with an rtos driver part of it, but I hope it helps :)
Ps you can find more lib_xcore documentation in the tools guide here https://www.xmos.com/documentation/XM-0 ... e-api.html#

Cheers
Pavel
xmos software engineer