cancel
Showing results for 
Search instead for 
Did you mean: 

i am using STM32F303E-eval board with MCU stm32f303vc and i am trying to use UART2 at 312500 baud rate but i am unable to received correct information.

Rkuma.1964
Associate II

please tell me whether it is eval board hardware problem or not, but i cam able to achieve 312500 baud rate for UART1.

thanks.

2 REPLIES 2
berendi
Principal

Is it USART1 or USART2 then? Note that all possible pin mappings for USART2 are connected to onboard peripherals on the eval board, it might be possible to use it after removing some bridges or jumpers first. Check the board user manual if you have meant USART2.

USARTs can have different clock sources. Check out RCC_CFGR3 in the reference manual. You might want to switch the clock source to SYSCLK for better accuracy, you can do it by

RCC->CGFR3 |= RCC_CFGR3_USART1SW_0;

for USART1, or

RCC->CGFR3 |= RCC_CFGR3_USART2SW_0;

for USART2. Other clock sources are possible, but they'd make sense mostly for lower baud rates.

Now check the system clock frequency. Verify that it's really what you think it is (and what the application requires). You can output it to the MCO pin and check with an oscilloscope. (Enable GPIOA clock in the RCC, set PA8 to alternate mode, function 0, set RCC_CFGR_MCO_2)

Calculate the baudrate divisor, divide the system clock frequency with the required baudrate, and round it to the nearest integer. Note the error introduced by rounding, at 8MHz system clock it can be as high as 1.5%. A proper UART should tolerate frequency deviations up to 5%, so this is indeed no problem in itself.

Enable the required USART and GPIO peripherals in RCC. Set the pins to alternate mode, and set the function number (from the datasheet).

Write the divisor calculated above into the USART1->BRR register, then issuing

USART1->CR1 |= USART_CR1_UE|USART_CR1_TE|USART_CR1_RE;

should get the USART going. If it still doesn't, double-check the register values and frequencies.

as i understood, i have to remove resister R22 and R12 as mention in eval board schematic(also attached image).

please reply whether my understanding is correct or not.