cancel
Showing results for 
Search instead for 
Did you mean: 

USART Baud Rate Error

glenn0010
Associate III

Hi All,

I am currently occasionally receiving corrupted data on my UART2 (STM32F302). By corrupted data I mean receiving a character which I am not expecting.

I am running a 32MHz UART2 Clock and using a baud rate of 9600 with oversampling at 16. So The BRR register should be 3333.33 = 3333

The error should be with the limits I presume. However in the register below I get confused with the BRR [3:0] bits. for OVER 8 = 0 which is what I am using its says that they should be the same as those of the USARTDIV.

Does that mean I should put 3333 in bits 4:15 and put the first 3 bits of 3333 in bits 0:3. Or should I just put 3333 from bits 0:15?

I am currently using the latter method and I am getting some corruption.

Thanks

1 REPLY 1
glenn0010
Associate III

So I have fixed it. Turns out the Keil C/C++ compiler was set to Level 0. I saw online someone had the same issue and he set it to <default> and it fixed it.