-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
gpio_set_level for GPIO_NUM_16 & GPIO_NUM_25 is not working for me. (IDFGH-5235) #7005
Comments
Problem DescriptionHey, Today I found something strange. Could someone help me with this. Even though I disable All GPIO Configs in my Code. Somehow intr_alloc is adding specific GPIO 16 & 25 to interrupt logics. Code to reproduce this issue// the code should be wrapped in the ```cpp tag so that it will be displayed better.
#include "esp_log.h"
void app_main(void)
{
// gpio_config_t io_conf;
// //disable interrupt
// io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
// //set as output mode
// io_conf.mode = GPIO_MODE_OUTPUT;
// //bit mask of the pins that you want to set,e.g.GPIO18/19
// io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
// //disable pull-down mode
// io_conf.pull_down_en = 0;
// //disable pull-up mode
// io_conf.pull_up_en = 0;
// //configure GPIO with the given settings
// gpio_config(&io_conf);
// //interrupt of rising edge
// io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
// //bit mask of the pins, use GPIO4/5 here
// io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
// //set as input mode
// io_conf.mode = GPIO_MODE_INPUT;
// //enable pull-up mode
// io_conf.pull_up_en = 1;
// gpio_config(&io_conf);
//change gpio intrrupt type for one pin
// gpio_set_intr_type(GPIO_INPUT_IO_0, GPIO_INTR_ANYEDGE);
//create a queue to handle gpio event from isr
// gpio_evt_queue = xQueueCreate(10, sizeof(uint32_t));
// //start gpio task
// xTaskCreate(gpio_task_example, "gpio_task_example", 2048, NULL, 10, NULL);
//install gpio isr service
// gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
//hook isr handler for specific gpio pin
// gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
// //hook isr handler for specific gpio pin
// gpio_isr_handler_add(GPIO_INPUT_IO_1, gpio_isr_handler, (void*) GPIO_INPUT_IO_1);
//remove isr handler for gpio number.
// gpio_isr_handler_remove(GPIO_INPUT_IO_0);
// //hook isr handler for specific gpio pin again
// gpio_isr_handler_add(GPIO_INPUT_IO_0, gpio_isr_handler, (void*) GPIO_INPUT_IO_0);
int cnt = 0;
// while (1){
gpio_set_level(BM_LITE_RST_N,HIGH);
ESP_LOGD(TAG,"BM_LITE_IRQ GPIO Level: %d",gpio_get_level(BM_LITE_IRQ));
ESP_LOGD(TAG,"LOCK_PLATE_FEEDBACK GPIO Level: %d",gpio_get_level(LOCK_PLATE_FEEDBACK));
// }
// while(1) {
// printf("cnt: %d\n", cnt++);
// vTaskDelay(1000 / portTICK_RATE_MS);
// gpio_set_level(GPIO_OUTPUT_IO_0, cnt % 2);
// gpio_set_level(GPIO_OUTPUT_IO_1, cnt % 2);
// }
}
// If your code is longer than 30 lines, GIST is preferred. Debug Logs
|
This has nothing to do with gpios, interrupt sources have their own numbering system |
But As I Can see clearly, I can't able set the level for these GPIOs to High without Calling it in loop. But Other GPIOs are working fine. I even tried to declared them as a Inputs. In that case it works fine. What may be reason?. |
Try something more rudimentary like the below.
Note the following IOs are used for flash/ram and SHOULD not be used for general ios:
|
I tried this. But it didn't show any progress. The issue is still there. |
But I can't able use those pins as output. Particularly , GPIO16, 17 and 25. Which is connected to the intr_alloc. Can you please help me with this.? |
@negativekelvin Can I get any suggestion regard this. I am still getting this issue. even after I update esp-idf to v4.3. |
Hi @Dineshkumar-J , Your issue looks like a concurrency issue, I wonder if there are too many controller for the same GPIO. Are you using gpio_set_level in different threads for GPIO16 and GPIO25 respectively? btw, using interrupt will not reduce your problem, unless you are moving all the code into the interrupt, otherwise you are just adding one possible controller for the GPIO to make it more uncontrollable. Another thought, as you say, if your code is simpled enough (only one task), and looks very like the example but still can't work. The only difference between your code and the example is the sdkconfig. Maybe you can compare the sdkconfig of the example, and your project. Michael |
GPIO_NUM_17 & GPIO_NUM_16 are used on the chips that use the PSRAM, however, the chip I use (Sparkfun ESP32 microcode) has no PSRAM, however, I can not control it as output |
Hi @mkeyno ,
But before continue debugging, I suggest check if those pins are break out on your devkit first. If you are sure your devkit vendor supports that, please come up with:
btw, I think this issue (package related) is case by case, next time please open a new issue, instead of replying under the same topic. This topic will be closed as soon as this discussion is resolved. |
Thanks for reporting, will close due to short of feedback, feel free to reopen. |
For now, there is a function to check whether a pin on the current SoC is reserved for other purpose, for example: #include "esp_gpio_reserve.h"
...
uint32_t pin = 16;
bool is_reserved = esp_gpio_is_pin_reserved(pin); |
Hello from 2025! They did change location of the include file as well as the function name. |
Environment
Problem Description
//Detailed problem description goes here.
I have on going project which has binary size of 1457 KB.
When I try to gpio_set_level(GPIO_NUM_16,1) after initializing everything properly, that GPIO 16 it is not set to High.
Expected Behavior
When I call for gpio_set_level(GPIO_NUM_16,1). It has to set to High.
Actual Behavior
It is not Set to High. But when I call it in While loop without any delay or any other function it is set to high.
Steps to reproduce
I have tried to modify the gpio example code. it works perfectly. but when I tried to add it to my project it is not working.
I even tried to disable entire program logic. and just used the same code as like as example. But result is same.
And I tried to call the gpio_set_level in a loop which makes it work
This is happening only for the GPIO_NUM_16 and GPIO_NUM_25. other GPIOs are working perfectly.
Code to reproduce this issue
// If your code is longer than 30 lines, GIST is preferred.
Debug Logs
The text was updated successfully, but these errors were encountered: