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

Why gpio34 can't receive input level? (IDFGH-14795) #15532

Open
3 tasks done
Ares-bit opened this issue Mar 7, 2025 · 2 comments
Open
3 tasks done

Why gpio34 can't receive input level? (IDFGH-14795) #15532

Ares-bit opened this issue Mar 7, 2025 · 2 comments
Assignees
Labels
Status: Opened Issue is new

Comments

@Ares-bit
Copy link

Ares-bit commented Mar 7, 2025

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

board: ESP32-WROOM-32
ide: ESP-IDF
version: v5.2

expect:
I connect a button between VIN and GPIO34(input mode, posedge trigger), and connect a LED light to GPIO27(output mode). I expect that when I press the button, GPIO34 should give an interrupt and set GPIO27 to high level to turn on the LED light.

fact:
I don't press the button, GPIO34 continuely give interrupts by itself.

question:
Why this would happen? I don't even press the button, GPIO34 should have no input, where does it receive input? What should I do to stop GPIO34 interrupt?

@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 7, 2025
@github-actions github-actions bot changed the title Why gpio34 can't receive input level? Why gpio34 can't receive input level? (IDFGH-14795) Mar 7, 2025
@songruo
Copy link
Collaborator

songruo commented Mar 7, 2025

To debug such issue, please first disconnect any external hardware from the board. Make sure no continuous GPIO interrupt will gets triggered with the devkit itself.

How did you initialize the IO and register the interrupt? Did you take the generic_gpio example as a reference?

@Ares-bit
Copy link
Author

Ares-bit commented Mar 7, 2025

To debug such issue, please first disconnect any external hardware from the board. Make sure no continuous GPIO interrupt will gets triggered with the devkit itself.

How did you initialize the IO and register the interrupt? Did you take the generic_gpio example as a reference?

Hi songruo,

I'm sure remove all peripheral from board, it does receive input.
This is my sample:

#include <stdio.h>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"

//34 input
#define INPUT_GPIO  GPIO_NUM_34

//27 ouput
#define OUTPUT_GPIO GPIO_NUM_27

void task_trig(void* arg)
{
    while (1) {
        ESP_LOGI("main", "idle");
        vTaskDelay(pdMS_TO_TICKS(1000));
    }
}

static int light = 0;

static void IRAM_ATTR button_intr(void* arg)
{
    ESP_DRAM_LOGI("isr", "button press!");
    light = !light;
    gpio_set_level(OUTPUT_GPIO, light);
}

void app_main(void)
{
    gpio_install_isr_service(0);

    gpio_config_t input_gpio = {
        .mode = GPIO_MODE_INPUT,
        .intr_type = GPIO_INTR_POSEDGE,
        .pin_bit_mask = (1ULL << INPUT_GPIO),
        .pull_down_en = GPIO_PULLDOWN_ENABLE,
    };

    gpio_config(&input_gpio);

    gpio_config_t output_gpio = {
        .mode = GPIO_MODE_OUTPUT,
        .intr_type = GPIO_INTR_DISABLE,
        .pin_bit_mask = (1ULL << OUTPUT_GPIO),
        .pull_down_en = GPIO_PULLDOWN_ENABLE,
    };

    gpio_config(&output_gpio);

    gpio_isr_handler_add(INPUT_GPIO, button_intr, NULL);

    xTaskCreatePinnedToCore(task_trig, "button", 2048, NULL, 3, NULL, 1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants