Is this console subsystem somehow setup by default to prevent this???
https://docs.espressif.com/projects/esp ... nsole.html
Thanks for any help, this is extremely frustrating.
***
I asked a version of this question earlier, but didn't get any replies. Usually that means that my question wasn't asked well, or the code *should* work and the problem is something else. I'll ask again in case I asked it poorly.
I am using a ESP-32 dev kit (ESP32-C6-DevKitC-1), and trying to establish basic UART comms. I've started with the wifi/scan example, which runs fine. The pin layout, for reference, is here:
https://docs.espressif.com/projects/esp ... layout.png
I'm able to both send and received over UART1 using this code:
Code: Select all
void UART_Initialize_WorksOn10and11()
{
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
};
SMILE_UART_NUM = UART_NUM_1;
esp_err_t r;
const int uart_buffer_size = (1024 * 2);
QueueHandle_t uart_queue;
r = uart_driver_install(SMILE_UART_NUM, uart_buffer_size, uart_buffer_size, 10, NULL, 0);
r = uart_param_config(SMILE_UART_NUM, &uart_config);
r = uart_set_pin(SMILE_UART_NUM, 11,10, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
}
void UART_ReadLoop()
{
int reported_length = 0;
esp_err_t r;
r = uart_get_buffered_data_len(SMILE_UART_NUM, (size_t*)&reported_length);
int bytes_to_read = reported_length;
int bytes_read = uart_read_bytes(SMILE_UART_NUM, m_RxBuffer, reported_length, 0);
if (bytes_read > 0)
{
printf("Read '%s'\n", m_RxBuffer);
}
}
Code: Select all
void UART_Initialize_DoesntWorkOnUART0()
{
uart_config_t uart_config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
};
SMILE_UART_NUM = UART_NUM_0; // *** CHANGED FOR UART0
esp_err_t r;
const int uart_buffer_size = (1024 * 2);
QueueHandle_t uart_queue;
r = uart_driver_install(SMILE_UART_NUM, uart_buffer_size, uart_buffer_size, 10, NULL, 0);
r = uart_param_config(SMILE_UART_NUM, &uart_config);
r = uart_set_pin(SMILE_UART_NUM, UART_PIN_NO_CHANGE,UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); // *** CHANGED FOR UART0
}
Why would UART1 work on RX, but not RX over UART0, using near-identical code and connecting to the specified pins?
Thanks for any insight... reaching my wits end on this one.
UPDATE: By the way, if you looked at this post (thank you), checked out the code and do NOT see a problem, if it SHOULD work, that would be helpful to know too...