-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Should be possible to digitalRead() a pin that's not GPIO #10370
Comments
Hi @egnor, can you please give it a test without the check So this may work for some pins of peripherals, but may not for everything. PS: Thanks for very nice report. |
Similar issue with pinMode(): |
@vvb333007 What is the point of setting Did you have any time to properly test the |
Yes it works if periman call is commented. I am just thinking that pinMode() must not call deinit when I just want to add 1 more flag, and do not reconfigure pin to GPIO funxtion. If I am manipulating flags on live UART TX pin for example I want that pin to remain UART TX, not switch to GPIO. As I see it that digitalWrite() is the function which must check the bus type and reconfigure pin to GPIO function on attempt to set digital value.
|
I am making a shell (a devel/debug tool) which among other things provides commands for pin manipulation. While I was I know that pin 6 is used internally for the memory access but still.. It is just only 1 flag was updated, other flags remain unchanged and it crashed. I looked into it and found that idf functions alone do not crash the whole sketch. Then I found this bug report and thats why I posted it here. Thats the full story. |
Another thing to consider: By default, many pins of ESP32 are routed through IO MUX and have function of GPIO. Such pins are ready to be used, however As such you are not able to digitalRead() interface pin (uart for example): it is either not readable because of what is said in the very first message, or it loses its IOMUX function (being uart_tx for example) because of pinMode(...). But yes as you just said anyone can simply use IDF function in their Arduino sketch to do such a specific stuff. Just a thought. |
Hi @P-R-O-C-H-Y, Issue with Using SD Card GPIO Pins on ESP32-CAM I am working with the ESP32-CAM and trying to use GPIO pins that are normally allocated for the SD card (e.g., GPIOs 2, 4, 12, 13, 14, 15) as general-purpose GPIOs. However, I am not using an SD card in my project and have ensured that the SD card functionality is not initialized in my code. Despite this, I encounter the following error: Is there a way to configure or free up these GPIO pins for general-purpose use on the ESP32-CAM? Thanks in advance for your help! |
Hi @SinekaRamu, first you need to call a |
pinmode for OUTPUT is working fine, While defining a input pin it gives wired output ` void loop() { |
Hi @P-R-O-C-H-Y , I followed the idea with setting the pinMode but it doesn't help either I set INPUT nor OUTPUT. There is a lib for CC1101 radio which stopped working after switching to new boards, in which there are actual calls for digitalRead from MISO pin: I am using the most popular WROOM based dev kit, where pin number 19 is a hardware MISO pin, so usage of it is intended. It is also listed as GPIO pin. We are using this lib for reading from WMBUS water meters in Supla software, which unfortunately had to move forward with boards. Do you have any other workaround or is there a chance to make it working as with boards 2.x.x? Best regards |
Solved with #11016 |
Board
All
Device Description
Any device
Hardware Configuration
Any configuration
Version
latest master (checkout manually)
IDE Name
any IDE
Operating System
any OS
Flash frequency
any frequency
PSRAM enabled
yes
Upload speed
any
Description
in arduino-esp32 3.x, if you attempt to
digitalRead()
from a pin that's been configured as another peripheral (e.g. I2C or UART), an error message comes back likeand the function always returns 0. in previous versions it was possible to see the state of the pin regardless of what peripheral is driving it (which is perfectly well supported by hardware). there are a number of use cases for this, for monitoring what a peripheral is actually doing, for seeing if something externally is overriding it, etc..
the code in question is here:
arduino-esp32/cores/esp32/esp32-hal-gpio.c
Line 187 in 7018cd1
(as far as I know,
gpio_get_level()
will always work even if the pin is driven by another peripheral, so I think the check can just be skipped?) if the change is intentional, it should probably be put in the migration document??Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: