1.
You enable USART2 (set UE in CR1) before setting the BRR. What is likely to happen?
-
The baud rate is wrong because the BRR write is ignored while UE = 1, so BRR stays 0, which is not a valid divisor (RM0490 requires USARTDIV of at least 16).
-
Correct. Always configure BRR before enabling the USART.
-
Nothing: the USART will wait for BRR to be written before operating.
-
The hardware does not wait. Once UE is set, BRR can no longer be written, so the later BRR write is ignored and BRR stays at its reset value of 0.
-
A hardware fault exception is triggered.
-
Writing registers in the wrong order does not cause a fault; it just produces incorrect behavior.
-
The USART works fine. Order does not matter.
-
Order matters. Enable the USART only after all other registers are configured.
