Uart1 won't transmit after esp_restart()

dedvalson
Posts: 6
Joined: Fri Feb 16, 2018 8:21 pm

Uart1 won't transmit after esp_restart()

Postby dedvalson » Tue Jan 08, 2019 11:03 pm

Hi,

I am using UART1 and it is working perfectly for me until an esp_restart() takes place. After that, nothing comes out of the transmit pin even though all of the calls return normal values.

A search has shown some issues regarding receiving (mostly in Arduino) but those all appear to be fixed and this is a transmit issue anyway.


Here is my initialization routine.

The arguments are port = UART_NUM_1, tx_io_num = 25, rx_io_num = 26.

Code: Select all

    esp_err_t NamPort::Initialize(uart_port_t port, int tx_io_num, int rx_io_num) {
        uart_config_t uart_config = {
            .baud_rate = 62500, 
            .data_bits = UART_DATA_8_BITS,
            .parity = UART_PARITY_DISABLE,
            .stop_bits = UART_STOP_BITS_1,
            .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
            .rx_flow_ctrl_thresh = 0,
            .use_ref_tick = false
        }; 
        Port = port;
        ESP_ERROR_CHECK(uart_param_config(Port, &uart_config));
        ESP_ERROR_CHECK(uart_set_pin(Port, tx_io_num, rx_io_num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
        const int uart_buffer_size = (1024 * 2); 
        QueueHandle_t uart_queue;
        // Install UART driver not using an event queue
        ESP_ERROR_CHECK(uart_driver_install(Port, uart_buffer_size, 0, 10, &uart_queue, 0));
        for (int i = 0; i < 5; i++) {
            if (InitRF()) {
                start();
                return ESP_OK;
            }
        }
        return ESP_ERR_NOT_SUPPORTED;
    }
My data transmit routine is just this:

Code: Select all

    void NamPort::SendMsg(byte* msg, size_t size) {
        size_t sent = uart_write_bytes(Port, (const char*)msg, size);
        assert(sent == size);
    }
After the reset, uart_write_bytes continues to return the correct number of bytes (the assert does not fire). All of the initialization code appears to work also, all of the ESP_ERROR_CHECKs succeed. From a software standpoint there is no way to tell it isn't working but a serial communications analyzer connected directly to the chips pins doesn't see any data come out after the reset. After a hardware reset it works fine. Since all of the calls work normally, I have a suspicion that the mux isn't getting set up right to get the uart to the correct pins, but this is just a guess. Receive may be broken also, but unless I can transmit I will never get a response to find out.

I am using the Release/v3.2 code branch from GitHub. I sure would appreciate any suggestions or workarounds.

Thanks,

Don

dedvalson
Posts: 6
Joined: Fri Feb 16, 2018 8:21 pm

Re: Uart1 won't transmit after esp_restart()

Postby dedvalson » Thu Jan 10, 2019 4:03 pm

I was able to solve this (sort of). There was some old code in the project from when those pins used to be used for an I2C interface. During the exit process, those pins wound up getting claimed for I2C. Something from that persisted through the restart and the UART wound up not having the pins.

By not doing the assignment to I2C (which shouldn't have been happening anyway) the problem went away.

Having said that though, it doesn't seem like anything that is done prior to the restart should have any effect on what happens afterwards, so I do think there is a minor bug there.

Thanks,

Don

Ritesh
Posts: 722
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Uart1 won't transmit after esp_restart()

Postby Ritesh » Fri Jan 11, 2019 5:11 pm

dedvalson wrote:
Thu Jan 10, 2019 4:03 pm
I was able to solve this (sort of). There was some old code in the project from when those pins used to be used for an I2C interface. During the exit process, those pins wound up getting claimed for I2C. Something from that persisted through the restart and the UART wound up not having the pins.

By not doing the assignment to I2C (which shouldn't have been happening anyway) the problem went away.

Having said that though, it doesn't seem like anything that is done prior to the restart should have any effect on what happens afterwards, so I do think there is a minor bug there.

Thanks,

Don
But you can either work on any particular interface at a time. So, that is your problem like you are using multiple interface at a time on single pin.
Regards,
Ritesh Prajapati

Return to “ESP32 IDF”

Who is online

Users browsing this forum: No registered users and 17 guests