I am trying to use GPIO 21 on ESP32 C3 for UART0 TX. I would like uses it with open drive feature.
I have tried with API and with register level instructions.
In API the instructions are the follow:
ESP_ERROR_CHECK(uart_param_config(S_BusPort, &uart_config_1));
ESP_ERROR_CHECK (uart_driver_install(S_BusPort, 1024, 1024, 0, NULL, 0));
……
ESP_ERROR_CHECK(uart_set_pin(S_BusPort, 21, 20, -1, -1));
……
ESP_ERROR_CHECK(gpio_set_direction (GPIO_NUM_21, GPIO_MODE_OUTPUT_OD));
ESP_ERROR_CHECK(gpio_pullup_en(GPIO_NUM_21));
The TX UART signal come out properly but not in open drain mode (both the rising and falling fronts are very steep).
Using register the instruction are the follow:
ESP_ERROR_CHECK(uart_param_config(S_BusPort, &uart_config_1));
ESP_ERROR_CHECK (uart_driver_install(S_BusPort, 1024, 1024, 0, NULL, 0));
……
REG_WRITE(GPIO_FUNC21_OUT_SEL_CFG_REG,0x006); //connect UART0 output signal to GPIO21
REG_WRITE(GPIO_PIN21_REG,0x04); //open drain activated
REG_WRITE(IO_MUX_GPIO21_REG,0x0900); //pull up activated
Also in this case the output UART signal come out properly but not in open drain mode.
Is there some thing wrong? Can someone help me? Or, simply, doesn’t ESP32 C3 support open drain mode when the GPIO is linked to the UART0 TX signal?
Thanks in advance.
Best regards,
Freddy_13
TX UART open drain mode
Re: TX UART open drain mode
Did you found a way to use od in uart tx?
In esp-idf 4.4 it works using:
But not in 5.2.
In esp-idf 4.4 it works using:
Code: Select all
gpio_set_direction(tx_io_num, GPIO_MODE_OUTPUT_OD)
Re: TX UART open drain mode
I saw that new implementation connects gpio to gpio out signal when set direction.
I think one pad can be connected to only one signal. Then the serial signal are disconnected.
You can do an hack:
I think one pad can be connected to only one signal. Then the serial signal are disconnected.
Code: Select all
static esp_err_t gpio_output_enable(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
gpio_hal_output_enable(gpio_context.gpio_hal, gpio_num);
esp_rom_gpio_connect_out_signal(gpio_num, SIG_GPIO_OUT_IDX, false, false);
return ESP_OK;
}
Code: Select all
#include "hal/gpio_hal.h"
gpio_hal_context_t hal = {.dev = GPIO_HAL_GET_HW(GPIO_PORT_0)};
gpio_hal_od_enable(&hal, tx_io_num);
Who is online
Users browsing this forum: aygh4266, Bing [Bot] and 145 guests