UART minimum baudrate????

minDark
Posts: 2
Joined: Fri Mar 17, 2017 7:45 pm

UART minimum baudrate????

Postby minDark » Fri Mar 17, 2017 7:55 pm

Hello to everyone! I need to know what is the minimum baud rate for the UART port. I have an OBD communication board and i need a baudrate of 5 BAUD, 7O1 format. I don't want to use software bit-banging or timers. Is it posible to set a baudrate of 5, if the main CLK is 240MHz??

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: UART minimum baudrate????

Postby ESP_Angus » Mon Mar 20, 2017 2:58 am

Wow, 5bps! With some practice you could almost whistle that baud rate!

Unfortunately I don't think this is supported via the UART peripheral, at least not yet. UART master clock is the APB clock which is 80MHz by default. The integer portion of the clock divider register is 20 bits wide, which gives a theoretical minimum speed of 76bps (I'm not certain a rate this low is actually supported either, would have to check). You would you need a 24 bit divider to divide 80MHz down to 5Hz.

In future I think we will support other APB clock frequencies and/or UART clock sources, but we don't support this right now.

The good news is, such a low bitrate should be very straightforward to bit-bang read as a "soft UART". I'd suggest using a GPIO interrupt to detect a start condition, and then enable a "timer group" timer to configure a timer interrupt, and read the pin as a GPIO from the ISR. At 240MHz you will have lots of spare time between each bit period. :)

Angus

User avatar
martinayotte
Posts: 141
Joined: Fri Nov 13, 2015 4:27 pm

Re: UART minimum baudrate????

Postby martinayotte » Mon Mar 20, 2017 7:14 pm

Wow ! that reminds me the age of Baudot Teletypes, but most of them were 75 baud.

minDark
Posts: 2
Joined: Fri Mar 17, 2017 7:45 pm

Re: UART minimum baudrate????

Postby minDark » Mon Mar 27, 2017 8:27 am

Thanks for answer! The 5baud will be TX only for a single byte and then switch the baudrate to 9600 or 10400. So no interrupt pin, just send a single byte @ 5 BAUD and then switch. For a regular serial port on windows i'm using break signal. ESP32 can send break signal for a specified length on UART? In IDF source code i see a function uart_set_break() witch should do the right thing.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: UART minimum baudrate????

Postby ESP_Angus » Mon Mar 27, 2017 11:21 pm

minDark wrote:ESP32 can send break signal for a specified length on UART? In IDF source code i see a function uart_set_break() witch should do the right thing.
Aha, that's a lot simpler than what I had imagined!

Try the uart_write_bytes_with_break() function, with the number of bytes set to zero:
http://esp-idf.readthedocs.io/en/latest ... Kc6size_ti

benpeoples
Posts: 10
Joined: Wed May 31, 2017 4:21 pm

Re: UART minimum baudrate????

Postby benpeoples » Wed May 31, 2017 4:28 pm

The uart_write_byte_with_break checks the length of the data and spits out an error on size 0. Currently looking for a solution for this, I use a protocol that starts packets with a BREAK...

Either allowing a 0 length data or a straight set_break command would be nice.

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: UART minimum baudrate????

Postby ESP_Sprite » Fri Jun 02, 2017 2:03 am

That's a bug, methinks. Could you do us a favour and report this on https://github.com/espressif/esp-idf/issues ? We have better tracking of issues there than on the forums here.

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: UART minimum baudrate????

Postby papaluna » Thu Aug 02, 2018 2:27 pm

benpeoples wrote:The uart_write_byte_with_break checks the length of the data and spits out an error on size 0. Currently looking for a solution for this, I use a protocol that starts packets with a BREAK... Either allowing a 0 length data or a straight set_break command would be nice.
I also need to start a transmission that starts with a BREAK. Shall I create a github issue?
--
Paul.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: UART minimum baudrate????

Postby ESP_Angus » Fri Aug 03, 2018 5:58 am

I don't think an issue was ever opened, so yes please open one.

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: UART minimum baudrate????

Postby papaluna » Fri Aug 03, 2018 8:05 pm

ESP_Angus wrote:I don't think an issue was ever opened, so yes please open one.
Thanks.

A similar issue already exists https://github.com/espressif/esp-idf/issues/703 According to @costaud, the hardware apparently does not support sending a BREAK before a data transmission, and the UART Driver does not support sending empty data using uart_write_bytes_with_break().

A possible solution to send a BREAK condition (https://en.wikipedia.org/wiki/Universal ... _condition) can be achieved using uart_set_line_inverse() and so inverting the TX idle signal level from HIGH to LOW for a specific duration, and then reverting back to the original setup. The result looks good on the logic analyzer.

An example for an UART of 9600 baud: transmitting 1 character of 10 bits results in 10 frames and takes +-1millisec so a BREAK condition must set the signal Low for at least > 1 millisec and then set it High again.

Code: Select all

    uart_set_line_inverse(MY_UART_NUM, UART_INVERSE_TXD);
    ets_delay_us(2 * 1000);
    uart_set_line_inverse(MY_UART_NUM, UART_INVERSE_DISABLE);
    char autobaud_string[2] = { 0x55, '\0' };
    f_retval = uart_write_bytes(MY_UART_NUM, autobaud_string, strlen(autobaud_string));
This code works fine for the Microchip SN2483 Lora module to wake it up from sleep mode.
--
Paul.

Who is online

Users browsing this forum: No registered users and 106 guests