Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32C3 GPIO4 and GPIO5 not working #9

Closed
sehraf opened this issue Oct 29, 2021 · 9 comments · Fixed by #19
Closed

ESP32C3 GPIO4 and GPIO5 not working #9

sehraf opened this issue Oct 29, 2021 · 9 comments · Fixed by #19
Assignees

Comments

@sehraf
Copy link

sehraf commented Oct 29, 2021

I'm an unable to control GPIO 4 and 5. Matrix user jessebraham was able to reproduce this.
Other GPIOs behave as expected (using the same code as for GPIO4 and 5)

@mtorromeo
Copy link

I've been going crazy with this issue for a while.
Unless I manually reset the pins, most of them don't work, not just GPIO 4 and 5

    unsafe {
        gpio_reset_pin(gpio_num_t_GPIO_NUM_6);
        gpio_reset_pin(gpio_num_t_GPIO_NUM_7);
        gpio_reset_pin(gpio_num_t_GPIO_NUM_10);
    }

once I do this, everything works as expected

@sehraf
Copy link
Author

sehraf commented Nov 21, 2021

Thanks for the workaround 👍

@JurajSadel
Copy link

Thank you @mtorromeo!

@jessebraham
Copy link
Member

I believe that the IO MUX may not be being configured properly.

Referencing Table 5-2 in the ESP32-C3's TRM (v0.4) it seems that all the values in the Reset column correspond with GPIO functions, so that would explain why calling gpio_reset_pin fixes it.

However in IO_MUX_GPIOn_REG (Register 5.22 in TRM) we find:

IO_MUX_GPIOn_MCU_SEL Select IO MUX function for this signal. 0: Select Function 0; 1: Select
Function 1; etc. (R/W)

According to the register field diagram the reset value is 0, or Function 0. Looking again at Table 5-2 we see that Function 0 is not GPIO for the majority of pins.

Is it possible the default IO MUX config is causing some issue? I don't have the energy to investigate this right now but I can do some actual testing tomorrow and report back, just wanted to share my thoughts.

@1c3t3a
Copy link
Contributor

1c3t3a commented Nov 26, 2021

I experience the same issue with the LED (GPIO 8) on the esp32c3 Devkit M. For me even resetting doesn't change much, sometimes the LED goes on but not off and sometimes it doesn't work at all.

@2asoft
Copy link

2asoft commented Dec 1, 2021

I also experience this on an older esp32 devkit, and the workaround with resetting the pin helped.
The only pin that seems to have worked out of the box is io2, the rest required the workaround.

@ivmarkov
Copy link
Collaborator

ivmarkov commented Dec 5, 2021

@jessebraham - the ESP-IDF blinking LED sample seems to reset the pin prior to using it. Adding a pin reset code in the into_output / into_input methods and so on might be an OK workaround? What do you think?

@ivmarkov
Copy link
Collaborator

ivmarkov commented Dec 5, 2021

... and into the Pin::reset() method implementation perhaps as well.

@jessebraham
Copy link
Member

Resetting the pin seems to resolve the issue based on my limited testing. I think this is a fine solution for now.

I have a fix ready to PR, I'm just going to do a bit more testing before I submit it.

usbalbin pushed a commit to usbalbin/esp-idf-hal that referenced this issue May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants