Does Pyboard support 9-bit UART? #16152
-
Hi everyone! I’m working on a project that requires 9-bit UART support for data transmission. Does the standard MicroPython firmware for Pyboard support a 9-bit UART mode? If not, are there any custom builds available with this functionality? I’ve seen that the STM32 port had modifications allowing 9-bit mode, but I’m not sure if this applies to Pyboard specifically. Also, are there any plans to add full support for 9-bit UART on Pyboard in future MicroPython firmware releases? Any information or advice would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
The 9-bit mode should be available at the PyBoard and at the other STM32 devices. As far as I can tell from the code, the only condition is that parity has to be None. |
Beta Was this translation helpful? Give feedback.
-
Hi Robert, Thank you for the quick response! I’ve set up UART with 9-bit mode, but I’m encountering an issue when data is received. Specifically, as soon as data arrives, I get the following error: If I switch the UART to 8-bit mode (bits=8), everything works fine, and data is received without any issues. Here are the UART settings I’m using: For reference, here’s the version of MicroPython I’m using: Are there any known limitations or additional configurations required for 9-bit mode to work correctly on PyBoard? Or could this be an issue with my specific version of MicroPython? Thanks again for your help, and I would appreciate any insights or suggestions! |
Beta Was this translation helpful? Give feedback.
Same as with read. You have to pack a 9 bit value into 2 bytes, low order bits first. And then use uart.write() with the even number of bytes for sending. e.g. to send the value 0x161 as 9 bit quantity, use uart.write("\x61\x01"). You may create a separate function for format the message. It is important that you send the whole message in a single call to uart.write().