configuring UART
configuring UART
Hi -
I'm at a point in my project where I need to redirect my console/logging to a different UART than the default. I need to test the device running on battery power, and currently the only way to do this is to unplug the cable that provides serial communications as well as power. I tried just disconnecting the power line (leaving the others intact) but that didn't work, as evidently the UART derives its power from the cable.
Anyway, according to the WROOM datasheet, UART1 uses pins 17 and 18. I've tried to do some reading on this, but I can't find the answer: what do I need to do in order to configure these pins for this purpose?
Thanks...oh, and if anyone has a better idea for how to keep getting logs after I "pull the plug" then I'd love to hear them.
I'm at a point in my project where I need to redirect my console/logging to a different UART than the default. I need to test the device running on battery power, and currently the only way to do this is to unplug the cable that provides serial communications as well as power. I tried just disconnecting the power line (leaving the others intact) but that didn't work, as evidently the UART derives its power from the cable.
Anyway, according to the WROOM datasheet, UART1 uses pins 17 and 18. I've tried to do some reading on this, but I can't find the answer: what do I need to do in order to configure these pins for this purpose?
Thanks...oh, and if anyone has a better idea for how to keep getting logs after I "pull the plug" then I'd love to hear them.
Re: configuring UART
If you have another usb-uart cable you should be able to attach it to the uart0 pins
Re: configuring UART
Haven't tried uart1 yet, but what I have been doing was to create a telnet server on it.
Re: configuring UART
I'm not sure I understand you, but attaching another cable to UART0 won't help if the UART stops working when I disconnect the power line.WiFive wrote:If you have another usb-uart cable you should be able to attach it to the uart0 pins
Re: configuring UART
So, here's what I've done so far:
1. added a header that connects to pins 17 and 18 (per the manual).
2. Connected an FTDI cable to the header. Shows up as COM3.
3. changed make->menuconfig->ESP32-specific as follows:
- UART for console output: Custom
- UART peripheral to use for console output (0-1): UART1
- UART TX on GPIO#: 18
- UART RX on GPIO#: 17
I'm not seeing anything. Any idea what I might be doing wrong?
Thanks...
1. added a header that connects to pins 17 and 18 (per the manual).
2. Connected an FTDI cable to the header. Shows up as COM3.
3. changed make->menuconfig->ESP32-specific as follows:
- UART for console output: Custom
- UART peripheral to use for console output (0-1): UART1
- UART TX on GPIO#: 18
- UART RX on GPIO#: 17
I'm not seeing anything. Any idea what I might be doing wrong?
Thanks...
Re: configuring UART
Hi Paul -
I'm afraid I don't understand. Yes, the device is connected to UART0, but why should that make working with UART1 difficult?
There exists an option in menuconfig to change where log messages are sent. I'd be happy if I could just get this working, but no luck so far.
I'm afraid I don't understand. Yes, the device is connected to UART0, but why should that make working with UART1 difficult?
There exists an option in menuconfig to change where log messages are sent. I'd be happy if I could just get this working, but no luck so far.
Re: configuring UART
If the usb-uart chip on the board doesn't allow those pins to hi-z float when it is powered down then it could be a problem. The uart itself should still work fine.mzimmers wrote:I'm not sure I understand you, but attaching another cable to UART0 won't help if the UART stops working when I disconnect the power line.WiFive wrote:If you have another usb-uart cable you should be able to attach it to the uart0 pins
Re: configuring UART
Hi,
sorry, I didn't get your demand correctly before, so I delete my post because the
answer doesn't help.
linuxpaul
sorry, I didn't get your demand correctly before, so I delete my post because the
answer doesn't help.
linuxpaul
Re: configuring UART
Hi Wifive -
I'd prefer to get UART1 working. I had initially assumed that merely making the changes in menuconfig would be adequate. But it occurred to me -- do I also need to set communications parameters/pins and install a driver for UART1?
I'd prefer to get UART1 working. I had initially assumed that merely making the changes in menuconfig would be adequate. But it occurred to me -- do I also need to set communications parameters/pins and install a driver for UART1?
Re: configuring UART
So, I decided to ignore logging for now, and just concentrate on writing to UART1.
Here's my setup code:
And here's my write code:
I get no error messages, but nothing is showing up in my PuTTY terminal that I have connected to UART1.
Can someone see something I'm doing wrong?
Thanks...
Here's my setup code:
Code: Select all
uart_config_t uart_config;
uart_config.baud_rate = 115200;
uart_config.data_bits = UART_DATA_8_BITS;
uart_config.parity = UART_PARITY_DISABLE;
uart_config.stop_bits = UART_STOP_BITS_1;
uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
uart_config.rx_flow_ctrl_thresh = 122;
uart_config.use_ref_tick = true;
// load the configuration.
err = uart_param_config(CD_UART_NBR, &uart_config);
if (err == ESP_OK)
{
ESP_LOGI(TAG, "uart_param_config() successful.");
}
else
{
ESP_LOGE(TAG, "uart_param_config() returned %s.", esp_err_to_name(errno));
}
//Set UART pins.
uart_set_pin(CD_UART_NBR,
18, // tx
17, // rx
UART_PIN_NO_CHANGE, // rts
UART_PIN_NO_CHANGE); //cts
if (err == ESP_OK)
{
ESP_LOGI(TAG, "uart_set_pin() successful.");
}
else
{
ESP_LOGE(TAG, "uart_set_pin() returned %s.", esp_err_to_name(errno));
}
//Install UART driver, and get the queue.
err = uart_driver_install(CD_UART_NBR, (BUF_SIZE * 2), (BUF_SIZE * 2), 20, &m_uartQueue, 0);
if (err == ESP_OK)
{
ESP_LOGI(TAG, "uart_driver_install successful.");
}
else
{
ESP_LOGE(TAG, "uart_driver_install returned() %s.", esp_err_to_name(errno));
}
}
Code: Select all
char buff[] = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (;;)
{
err = uart_write_bytes(UART_NUM_1, buff, strlen(buff));
if (err >= 0)
{
ESP_LOGI(TAG, "uart_write_bytes wrote out %d bytes.", err);
}
else
{
ESP_LOGE(TAG, "uart_write_bytes returned %d.", err);
}
vTaskDelay(100);
}
Can someone see something I'm doing wrong?
Thanks...
Who is online
Users browsing this forum: No registered users and 184 guests