I am using the uart module with 8bit data, even parity, 1 stop bit. (using the uPy Board as a bootrap loading device for MSP430 uPs).
Initalisation is as follows:
Code: Select all
uart = pyb.UART(4)
uart.init(9600, bits=8, parity = 0)
txdata = struct.pack('<BBB', 0x81, 0xaa,0x80)
uart.write(txdata)
I tried with different options (parity = 1 etc), checked the strmhal C sources and finally the STM4 family guide on this issue.
I was surprised to see that the guide states on page 957 that the parity bit is included in Bit 8 if the uart is configured in 8 Bit mode. So I tried it with bits=9 and here we go: all correct.
So as a summary: If parity bits are used, then the word-length must be 9 bits? If so a clarification in the code/examples might be helpful.
Googling around for a definition on this subject mainly describes the parity bit as an addition to the word-length (e.g. 8E1 means 8bit data, even parity, 1 stop bit where the parity bit is separate from the actual 8bit data).
BTW:
Really enjoying the boards - working flawlessly!
Martin
PS: maybe a small hint on the quick example page that the uart.write command is valid only since october might be helpful (previously it was uart.send).