pulldown enable blocks
Posted: Fri Sep 27, 2019 2:37 pm
Hello,
Sorry to ask basic things but, I tried this code:
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,
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);
}
Since I set GPIO_PULLDOWN_ENABLE, the interruption is not called and the button does not work.
I do not understand.
Regards,