espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.41k stars 7.37k forks source link

Pulse to low when pin mode set to OUTPUT_OPEN_DRAIN #9300

Open davidk88 opened 7 months ago

davidk88 commented 7 months ago

Board

ESP32-S3 WROOM-1 M0N16R8

Device Description

AI-S3 devkit

Hardware Configuration

none

Version

v2.0.14

IDE Name

PlatformIO

Operating System

Windows 10

Flash frequency

40 Mhz

PSRAM enabled

yes

Upload speed

921600

Description

First time after external reset, a short pulse to low is generated when pin mode set to output open drain. I have external pull-up. Pulse is not generated if device is reset with ESP.restart().

Sketch

pinMode(1, OUTPUT_OPEN_DRAIN);

Debug Message

none

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

davidk88 commented 7 months ago

Hello,

my problem is that I need to have reset line connected to another micro. I don't want to be reset when esp is reset. When gpio mode is set it should stay in hi-z by default. Tested on IO1, IO2, IO12

Here is a waveform: image

lbernstone commented 7 months ago

Do you have the same drop if you call the config directly?

  int mypin = 2;
  gpio_config_t conf = {
      .pin_bit_mask = (1ULL<<mypin),
      .mode = (gpio_mode_t)(GPIO_MODE_OUTPUT | GPIO_MODE_DEF_OD),
      .pull_up_en = GPIO_PULLUP_DISABLE,
      .pull_down_en = GPIO_PULLDOWN_DISABLE,
      .intr_type = GPIO_INTR_DISABLE
  };
  gpio_config(&conf);
davidk88 commented 7 months ago

With your code is like this:

image

1: reset button pressed 2: reset button released (short pulse to low) 3: gpio initialized with your code (5 seconds delay from setup start)

seems that default value for output open drain is low?

lbernstone commented 7 months ago

Or my code is bad :) In any case, it shows that the issue is at the hardware level, either physical init or the bootloader. I'd open an issue at ESP-IDF and see if they have an answer for you. It's not something that could be fixed through arduino-esp32.

SuGlider commented 6 months ago

External reset like pressing RESET button? Not sure if this can be changed.

Please give it a try with gpio_hold_en(gpio_num_t gpio_num) and gpio_hold_dis(gpio_num_t gpio_num) humm.... you want to keep OD state... HARD RESET will set all regiters to initial state. I don't think that any Microcontroller could do it, unless OD is the initial reset state of the GPIO.

It may be necessary some external hardware circuit.