Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4906

General • Re: gpio_set_inover does not invert input signal

$
0
0
I think that gpio_set_inover has no effect because you are using the gpio with the PIO module.
No, the input override also affects the value seen by the PIO module. I've used it myself with GPIO_OVERRIDE_LOW feeding a PIO program (in my case to get various things all initialised before the PIO program starts doing anything).

The invert can occasionally be useful with PIO programs for the JMP PIN instruction - which always takes the jump on pin high; if you want action on the pin being low you can usually re-write the code turning loops inside-out to achieve the same effect (ie. you make the JMP PIN the jump that closes the loop and drop through to the exception processing rather than having a loop with wrap or unconditional JMP and have the JMP PIN jump out for the exceptional case), but sometimes it can save an instruction to invert the pin input instead.

Note that gpio_set_inover() affects all reads from the pin - whether through the SIO (gpio_get() etc), the PIO, or any other function that might be enabled such as UART.

As a test, if you set the input override to invert but configure the pin as an output (and don't set the output override) then you should read back the opposite of what you write to the pin.

Statistics: Posted by arg001 — Tue Dec 03, 2024 1:17 pm



Viewing all articles
Browse latest Browse all 4906

Trending Articles