Uart1 won't transmit after esp_restart()

dedvalson
Posts: 8
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: 8
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: 991
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

ESP_houwenxiang
Posts: 66
Joined: Tue Jun 26, 2018 3:09 am

Re: Uart1 won't transmit after esp_restart()

Postby ESP_houwenxiang » Sun Jan 20, 2019 4:48 am

Hi, dedvalson
Did you solve your problem?

thanks !!
wookooho

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

Re: Uart1 won't transmit after esp_restart()

Postby Ritesh » Sun Jan 20, 2019 8:39 am

ESP_houwenxiang wrote:
Sun Jan 20, 2019 4:48 am
Hi, dedvalson
Did you solve your problem?

thanks !!

Hi,

I believe he was doing multiple interface on same pin which was causing issue. so might be problem will be resolved after using it for only one specific interface at a time.
Regards,
Ritesh Prajapati

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

Re: Uart1 won't transmit after esp_restart()

Postby dedvalson » Thu Jan 31, 2019 11:57 am

Hi,

Yes, I was doing multiple interface on the same pin, which was bad and caused the problem. However this multiple interface only happened as I was shutting down for a reboot. So yes it was my bad and I fixed the old code and the problem went away. However I still feel like the act of calling esp_restart should "undo" the bad thing that was happening prior to esp_restart.

The sequence was like this:

Power Up
UART works great
Do something that requires a reboot to happen
Accidentally use the UART pins for I2C
call esp_restart
UART doesn't work

So the restart doesn't return the chip to the same state as the power up. So I fixed my stupid problem but it still seems like the esp_restart should have undone the damage done prior to the shutdown.

Anyway, my issue is solved.

Don

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

Re: Uart1 won't transmit after esp_restart()

Postby Ritesh » Thu Jan 31, 2019 5:44 pm

dedvalson wrote:
Thu Jan 31, 2019 11:57 am
Hi,

Yes, I was doing multiple interface on the same pin, which was bad and caused the problem. However this multiple interface only happened as I was shutting down for a reboot. So yes it was my bad and I fixed the old code and the problem went away. However I still feel like the act of calling esp_restart should "undo" the bad thing that was happening prior to esp_restart.

The sequence was like this:

Power Up
UART works great
Do something that requires a reboot to happen
Accidentally use the UART pins for I2C
call esp_restart
UART doesn't work

So the restart doesn't return the chip to the same state as the power up. So I fixed my stupid problem but it still seems like the esp_restart should have undone the damage done prior to the shutdown.

Anyway, my issue is solved.

Don
Great. But I have still one question like if you restart board then it should be restarted again with its new state machine. So, As you have said earlier that before restarting board you have used same UART pin as I2C channel but as you restart board it should be started with fresh state machine for UART configuration as well.

So, Did you check again like are you doing proper initialization method for UART pins as well?
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Bing [Bot] and 20 guests