Hello,
I am trying to configure the two GPIO pins on my custom ESP32S2 board (connected to a switch ) as interrupts.
But the values I read from the pins after configurations are quiet strange. Can someone please help me to figure out whats going wrong here.
Thank you
[Codebox]void app_main()
{
//zero-initialize the config structure.
gpio_config_t io_conf;
//SwitchA Interrupt
io_conf.intr_type = GPIO_INTR_ANYEDGE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = 1UL<<SwitchA;
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
io_conf.pull_up_en = 1;
io_conf.pull_down_en = 0;
gpio_config(&io_conf);
//SwitchB Interrupt
io_conf.intr_type = GPIO_INTR_ANYEDGE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = 1UL<<SwitchB;
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//enable pull-up mode
io_conf.pull_up_en = 1;
io_conf.pull_down_en = 0;
gpio_config(&io_conf);
//change gpio interrupt type for one pin
gpio_set_intr_type(SwitchA, GPIO_INTR_ANYEDGE);
//change gpio interrupt type for one pin
gpio_set_intr_type(SwitchB, 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, "gpio_task", 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(SwitchA, gpio_isr_handler, (void*) SwitchA);
gpio_isr_handler_add(SwitchB, gpio_isr_handler, (void*) SwitchB);
[/Codebox]
ESP IDF GPIO Interrupt
-
- Posts: 11
- Joined: Thu Oct 14, 2021 2:56 pm
ESP IDF GPIO Interrupt
Last edited by enthusiastSR on Fri May 06, 2022 10:07 am, edited 1 time in total.
Re: ESP IDF GPIO Interrupt
It's likely similar to the issue I faced with interrupts for sleep modes.
What GPIO's are you using? If it's GPIO18+ this may be the issue.
Have a look around what I did here, it might help.
https://www.esp32.com/viewtopic.php?f=13&t=24900
What GPIO's are you using? If it's GPIO18+ this may be the issue.
Have a look around what I did here, it might help.
https://www.esp32.com/viewtopic.php?f=13&t=24900
Who is online
Users browsing this forum: No registered users and 121 guests