Problem with sendbreak in UART

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
martincho
Posts: 96
Joined: Mon May 16, 2022 9:59 pm

Re: Problem with sendbreak in UART

Post by martincho » Tue Jul 12, 2022 10:42 pm

lgrodzki wrote:
Tue Jul 12, 2022 1:06 pm
Hello, I have a problem, I installed micropython 1.19.1 on an esp32 and I need a sendbreak on the UART with more than 13 milliseconds. Unfortunately sendbreak has no duration option and it only lasts 8 milliseconds. Would there be any alternative to increase the sendbreak duration time in the UART?
This is a hack, but it might work. I don't have an ESP32 to test, sorry.

Define the transmit pin before you instantiate the serial port. Something like this (not tested and might require editing):

Code: Select all

uart_0_tx_pin = machine.Pin(<number>, machine.Pin.OUT)
After this, instantiate your serial port normally, and pass it the above Pin object for the TX pin.

You should be able to set the value of the pin at will and for your required duration.

Code: Select all

uart_0_tx_pin.value(1)
<some waiting code>
uart_0_tx_pin.value(0)
I know this hack works on the receive pin (on an RP2040) because I had to sense the output of a differential receiver to determine connectivity and this worked without any issues.

Well, I highlighted "before" for a reason. Don't do it after instantiating the UART or it will never be connected to the UART.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Problem with sendbreak in UART

Post by Roberthh » Wed Jul 13, 2022 5:41 am

For the SAMD port I implemented a similar approach, but within the sendbreak() function.

Post Reply