pulldown enable blocks

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

pulldown enable blocks

Postby oliverbru » Fri Sep 27, 2019 2:37 pm

Hello,

Sorry to ask basic things but, I tried this code:

Code: Select all

/* Hello World Example

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
*/
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "sdkconfig.h"

#define BLINK_GPIO_GREEN 25
#define BUTTON GPIO_NUM_12
#define ESP_INTR_FLAG_DEFAULT 0

 int BUTTON_PRESSED;

void blink_task(void *pvParameter)
{
    while (1)
    { 
        vTaskDelay(1000 / portTICK_PERIOD_MS);
        BUTTON_PRESSED = gpio_get_level(BUTTON);
        ESP_LOGI("test", "BUTTON STATE : %d", BUTTON_PRESSED);
        gpio_set_level(BLINK_GPIO_GREEN, BUTTON_PRESSED);
    }
}


static void IRAM_ATTR gpio_isr_handler()
{
    BUTTON_PRESSED = gpio_get_level(BUTTON);
    ets_printf("Button state : %d\n", BUTTON_PRESSED);
}

void app_main()
{
   
    gpio_pad_select_gpio(BLINK_GPIO_GREEN);
    gpio_set_direction(BLINK_GPIO_GREEN, GPIO_MODE_OUTPUT);

    gpio_config_t btn_config;
    btn_config.intr_type = GPIO_INTR_ANYEDGE ;
    btn_config.mode = GPIO_MODE_INPUT;               //Set as Input
    btn_config.pin_bit_mask = (1ULL << BUTTON); //Bitmask
    btn_config.pull_up_en = GPIO_PULLUP_DISABLE;     //Disable pullup
    btn_config.pull_down_en = GPIO_PULLDOWN_ENABLE; //Enable pulldown
    gpio_config(&btn_config);
    BUTTON_PRESSED = gpio_get_level(BUTTON);
    //install gpio isr service
    gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);

    //hook isr handler for specific gpio pin
    gpio_isr_handler_add(BUTTON, gpio_isr_handler, NULL);
    
    xTaskCreate(&blink_task, "blink_task", 1024*4, NULL, 1, NULL);
}
If I set GPIO_PULLDOWN_DISABLE, I have bounces.
Since I set GPIO_PULLDOWN_ENABLE, the interruption is not called and the button does not work.

I do not understand.

Regards,

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: pulldown enable blocks

Postby mikemoy » Fri Sep 27, 2019 5:32 pm

How is your button wired up ?

oliverbru
Posts: 14
Joined: Thu Sep 26, 2019 8:52 am

Re: pulldown enable blocks

Postby oliverbru » Fri Sep 27, 2019 11:00 pm

I attached the image.
Attachments
20190927_192017.jpg
20190927_192017.jpg (1.64 MiB) Viewed 4918 times

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: pulldown enable blocks

Postby mikemoy » Sat Sep 28, 2019 1:24 am

Thanks, however there is no way i can tell by the photo. Does your button have a pullup resistor? It does not look like it.,

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: pulldown enable blocks

Postby WiFive » Sat Sep 28, 2019 7:53 am

The button is connected to ground and the pulldown is connected to ground so all you will get is ground

Who is online

Users browsing this forum: No registered users and 88 guests