Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby papaluna » Tue Jan 30, 2018 2:54 pm

Hi,
Environment: the latest ESP-IDF from Github and the board Adafruit HUZZAH32 (rev1) and a sensor such as the KY-032 Obstacle avoidance sensor, the SW-180 Tilt Sensor, SW-420 Vibration Sensor which all output a digital signal 0 or 1.

I have configured the output pin interrupt type as GPIO_INTR_POSEDGE and I would expect that the interrupt handler is only triggered when the signal goes from 0 to 1.

Code: Select all

    io_conf.pin_bit_mask = (1ULL << GPIO_NUM_SENSOR);
    io_conf.mode = GPIO_MODE_INPUT;
    io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
    // @okay GPIO_INTR_ANYEDGE @problem GPIO_INTR_POSEDGE GPIO_INTR_NEGEDGE (they both behave the same as ANYEDGE!)
    io_conf.intr_type = GPIO_INTR_POSEDGE;
    ESP_ERROR_CHECK(gpio_config(&io_conf));
However, the interrupt handler is also triggered when the signal goes from 1 to 0 (the logic of GPIO_INTR_ANYEDGE).

How can I declare the interrupt handler to execute only when the signal goes from 0 to 1?

Gist:
https://gist.github.com/pantaluna/78f15 ... 05b6c11db6

-
Thanks,
Paul.
--
Paul.

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

Re: Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby ESP_Sprite » Wed Jan 31, 2018 2:18 am

Are you sure you don't just see the effect of contact bounce on the mechanical bits of your sensors?

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby papaluna » Wed Jan 31, 2018 10:33 am

Are you sure you don't just see the effect of contact bounce on the mechanical bits of your sensors?
I'm not sure but I don't think that is happening.

1. I have created a feedback loop in the GPIO MUX from the input sensor to the output LED (on the board) and the LED follows cleanly the changes to the pinvalue (0=off 1=on).

Code: Select all

void gpio_setup_gpiomux_sensor_to_led() {
    // @special ESP32 GPIO-MUX routes the incoming sensor signal to the on-board LED.
    // @special param3=true => invert pinvalue1=nothing detected (LED off) pinvalue0=obstacle detected (LED on).
    gpio_matrix_in(GPIO_NUM_SENSOR, SIG_IN_FUNC228_IDX, true);
    gpio_matrix_out(GPIO_NUM_LED, SIG_IN_FUNC228_IDX, false, false);
}
2. Both signals 0 and 1 comes through correctly when using the GPIO_INTR_ANYEDGE setting.

3. I pulled the latest master from Github but still the same problem.

X. Updated gist:
https://gist.github.com/pantaluna/78f15 ... 05b6c11db6

=> Any ideas?
--
Paul.

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

Re: Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby ESP_Sprite » Thu Feb 01, 2018 2:42 am

Sorry, I can't replicate this; I highly suggest you connect a scope or LA to your input signal.

Effectively, I've expanded your sample a bit: https://gist.github.com/Spritetm/bb22e5 ... 0e99db28eb . It now also outputs a 0.5Hz signal on GPIO14. Connecting that to GPIO21 leads to the expected behaviour, both for _POSEDGE as well as for _NEGEDGE.

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby papaluna » Thu Feb 01, 2018 8:59 am

Thanks for the test.

1. I have tried with various other pins but no luck.

2. I have a few other boards on order and I will retest with those.

3. Do you know if the default sdkconfig must be changed for the dev board Adafruit Huzzah32 ESP32 (on top of the Serial flasher config)?
https://learn.adafruit.com/adafruit-huz ... 32-feather
--
Paul.

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: Output pin interrupt type GPIO_INTR_POSEDGE behaves like GPIO_INTR_ANYEDGE

Postby papaluna » Thu Feb 01, 2018 9:19 am

Your test example works fine on my board.

Maybe I have to wire in stronger pullup resistor (they are still on order).
--
Paul.

Who is online

Users browsing this forum: No registered users and 96 guests