GPIO invert settings

michprev
Posts: 92
Joined: Fri Aug 04, 2017 8:57 pm

GPIO invert settings

Postby michprev » Thu Sep 27, 2018 10:47 am

Hi,
is there any case when GPIO_FUNCm_IN_INV_SEL, GPIO_FUNCn_OEN_INV_SEL and GPIO_FUNCn_OUT_INV_SEL can be useful?
See TRM V3.8 pages 68 and 69.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: GPIO invert settings

Postby ESP_igrr » Fri Sep 28, 2018 2:21 am

Input inverting is used, for example, in SDMMC driver for CD or WP pin, and in camera applications to match polarity of HSYNC/VSYNC signals to the ones expected by ESP32. I've seen one case where output inverting was used to flip the signal produced by LEDC, achieving some sort of phase modulation. Haven't seen uses of OE inverting yet.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: GPIO invert settings

Postby ESP_Sprite » Fri Sep 28, 2018 3:38 am

Output inversion is also used in some parallel I2S output things, if you want to change the polarity of e.g. the WS signal. I think I used OE inverting at some point as a shorthand to make a pin high-impedance with just one write, but I agree that I also struggle to come up with a specific use case for that.

saden123
Posts: 12
Joined: Tue Jul 24, 2018 12:18 am

Re: GPIO invert settings

Postby saden123 » Sat Oct 06, 2018 10:24 pm

mmmm, it pays to browse: I must look into this. I am toggling gpio for steppers within an ISR, and motor controllers vary in signal polarity for en, step and direction. So I am using this all over the code:

Code: Select all

#define GPIO_ON(gpioreg, inverse) \
    if (inverse)                  \
        GPIO.out_w1tc = gpioreg;  \
    else                          \
        GPIO.out_w1ts = gpioreg;
[edit]
Yep, this works (for anyone interested):

Code: Select all

WRITE_PERI_REG(GPIO_FUNCnn_OUT_SEL_CFG_REG, READ_PERI_REG(GPIO_FUNCnn_OUT_SEL_CFG_REG) | GPIO_FUNCnn_OUT_INV_SEL);
// nn=gpio number

Who is online

Users browsing this forum: Bing [Bot] and 62 guests