2025-12-10 1:48 AM
Hi everyone,
I’m working with an STM32L5 USART and trying to clarify a point about parity vs. MSB-first transmission.
From the reference manual (USART parity control / frame formats), when parity is enabled the frame formats are shown as:
M=00, PCE=1: SB | 7-bit data | PB | STB
M=01, PCE=1: SB | 8-bit data PB | STB
and there is a note that “in the data register, the PB is always taking the MSB position (8th or 7th depending on M)”.
This wording caused confusion in our class:
one interpretation is that because parity occupies the MSB position in the data register/word length, it might be transmitted before the data bits when MSBFIRST=1.
My understanding is:
MSBFIRST only reverses the order of the data bits inside the data field.
The parity bit remains the parity field in the frame, i.e. logically after the data field and before stop bits.
The “MSB position” note refers to the bit slot within the word length/data register, not to the time order on the line.
Could someone confirm:
Question:
When MSBFIRST is enabled or disabled, does the parity bit position in the transmitted frame change?
Or is it always the same frame structure (SB → data bits (order depends on MSBFIRST) → PB → stop)?
If possible, a short explanation referencing how the hardware maps parity into TDR/RDR vs. the actual serial bit timing would be very helpful.
Thanks!
Solved! Go to Solution.
2025-12-14 8:40 AM
This might've been better documented, but it's also easy to test. I've just did that, and it works so that the parity bit is always transmitted as the last bit in the frame, just before the stop bit, regardless of MSBFIRST setting.
In other words, MSBFIRST impacts only the ordering of data bits.
JW
2025-12-10 2:10 AM
A classic example of where a diagram can provide a far better description that words!
2025-12-11 10:20 AM
Thanks for your reply.
I agree that a diagram is helpful – that’s exactly why I’m asking. :)
What I’m trying to confirm is a very specific point about the STM32 USART:
- Does enabling MSBFIRST change the position of the parity bit in the transmitted frame, or not?
2025-12-14 8:40 AM
This might've been better documented, but it's also easy to test. I've just did that, and it works so that the parity bit is always transmitted as the last bit in the frame, just before the stop bit, regardless of MSBFIRST setting.
In other words, MSBFIRST impacts only the ordering of data bits.
JW
2025-12-14 9:05 AM
Thank you very much for testing this and confirming it.
Your explanation that the parity bit is always transmitted as the last bit before the stop bit, and that MSBFIRST only affects the ordering of the data bits, clears up the confusion I had when reading the reference manual.
This fully answers my question, thanks again!