circuitpython: ESP32-S3 and S2 issues with uarts - data output corrupt

CircuitPython version

Adafruit CircuitPython 7.3.0-beta.0 on 2022-04-01; ESP32-S3-DevKitC-1-N8R2 with ESP32S3

Code/REPL

>>> import board, busio
>>> uart1 = board.UART()
>>> uart1.deinit()
>>> uart1 = busio.UART(board.TX, board.RX, baudrate=38400)
>>> uart2 = busio.UART(board.IO17, board.IO18, baudrate=38400)
>>> uart1.write(b'abcdefghijklmnopqrstuvwxyz')
26
>>> uart2.write(b'abcdefghijklmnopqrstuvwxyz')
26
>>>

Behavior

Wrong data output, looks like maybe a queue issue: Here is what was seen on the Logic Analyzer

For uart1: image

For uart2: image

Description

No response

Additional information

Note: I also tried this with baud of 1000000 and also the data output was not correct.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30 (3 by maintainers)

Most upvoted comments

Probably the proper fix would be to change: void common_hal_busio_uart_construct(busio_uart_obj_t *self, to not call all of the individual setup functions within the idf, but instead call:

This sounds right to me. Thanks for digging into this!

You are welcome, If I get a chance and no one beats me to this, I may take a quick cut at updating that main setup function to use the method which sets up everything including clearing both hardware queues. But will probably be looking into a Teensy issue (Arduino)

A function like reset_output_buffer() would be also an option, because we already have the same for input.

Thought about that as well, but to do that fully would probably require changes to the IDF project, to add wrapper functions for the reset of the hardware queues, to then call the HAL functions I mentioned.

The reset_input_buffer method probably does not actually touch the hardware FIFO (could be wrong), but instead just clears the stuff that has been buffered by the software. Output wise we don’t buffer anything(Wish it did), except what is stuffed into the hardware buffer and then the code waits for the stuff to be output before the call returns .