gpio_config() call set PIN low immediately with PULLUP enabled

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

gpio_config() call set PIN low immediately with PULLUP enabled

Postby rsimpsonbusa » Fri Oct 18, 2024 3:59 pm

Hi everybody. Hope all is well. Long time.

Need some help/clarification.....please ESPIDF people.

I have a condition where after filling the required parameters to a gpio_config_t variable, specifically stating that I want a PULLUP on an Output pin, AND AND, having an external pull up resistor 1K (for good measure in case the pin does not have a pull-up), when the call is made to the gpio_config(&io_conf) the pin goes immediately LOW. No gpio_set_level() call yet.

Code: Select all

    
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_rom_gpio.h" 

void wait(char *title)
{
    printf("%s Ready\n",title);
    vTaskDelay(4000 / portTICK_PERIOD_MS);
    printf("Done\n");
}

void app_main(void)
{
    //zero-initialize the config structure.
    // wait("Start");
    // esp_rom_gpio_pad_select_gpio((gpio_num_t)14); 
    // wait("PadSelect"); 
    // gpio_reset_pin((gpio_num_t)32);
    // wait("ResetPIN");
    // gpio_set_pull_mode((gpio_num_t)14,GPIO_PULLUP_ONLY);
    // wait("SetPULLUP");
    // gpio_set_direction((gpio_num_t)14, GPIO_MODE_OUTPUT);
    // wait("SetDirection");

    gpio_config_t io_conf = {};
    io_conf.intr_type = GPIO_INTR_DISABLE;
    io_conf.mode = GPIO_MODE_OUTPUT;
    io_conf.pin_bit_mask = (1ULL<<32) ;
    io_conf.pull_down_en = 0;
    io_conf.pull_up_en = 1;
    wait("gpioConfig");
    gpio_config(&io_conf);


    while(true)
        vTaskDelay(1000 / portTICK_PERIOD_MS);

}

A led is connected that activates on LOW but also a multimeter test was repeatedly done. At this point the pin in question (tested 24,14,32, got tired) goes LOW, LED and multimeter detect this condition.

So I though the gpio_config() had something wrong....

Did a rom gpio programming (commented section) and put a "stepper x seconds" to see WHEN the pin goes LOW, it happens when you set the Direction.

WHY???? I need it to be HIGH on configuration (actually to do NOTHING).

Any help would be appreciated. CANNOT have that pin go LOW without my control a BOMB goes off :D even if 2 ms low time.

The solution would be to add Hardware, NPN transistor switch and activate on HIGH, but that is soooo lame...

RSN

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: gpio_config() call set PIN low immediately with PULLUP enabled

Postby boarchuz » Fri Oct 18, 2024 4:19 pm

You have set mode to GPIO_MODE_OUTPUT which will enable output. The level is determined by whatever is in the GPIO's output level register at that point in time. I assume this is 0 by default for all of them.

Use gpio_set_level *before* gpio_config to prepare the desired output level.

User avatar
ok-home
Posts: 78
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: gpio_config() call set PIN low immediately with PULLUP enabled

Postby ok-home » Fri Oct 18, 2024 4:24 pm

rsimpsonbusa wrote:
Fri Oct 18, 2024 3:59 pm
WHY???? I need it to be HIGH on configuration (actually to do NOTHING).
first set the level, then connect it to the output.
gpio_set_level(GPIO_NUM, 1);
gpio_set_direction(GPIO_NUM, GPIO_MODE_OUTPUT);

rsimpsonbusa
Posts: 131
Joined: Tue May 17, 2016 8:12 pm

Re: gpio_config() call set PIN low immediately with PULLUP enabled

Postby rsimpsonbusa » Fri Oct 18, 2024 5:18 pm

YES!!!!
Thanks for the wisdom!!!
Now the bomb is not going off WITHOUT my concent :D :D

Who is online

Users browsing this forum: No registered users and 193 guests