AnsweredAssumed Answered

STM32F103ZE USART baud rate over 115200

Question asked by galczynski.przemek on Jul 29, 2011
Latest reply on Jul 29, 2011 by Clive One

I have a little problem with setting a custom speed on the STM32 above 115200th The problem occurs both when using the init or manual configuration (manual calculation of values for the registry BRR).
There is no problem with different transmissions 9600, 28800 until 115200th After this value, the terminal is silent. Only by using the library function to initialize the USART to the terminal reached some wrong information. With manual configuration did not reach above the 115200th
Overall, I must dispel USART to 1Mb, because I make the servo controller which is at such a speed that communicates with the interface.

I would add that I am using win 7 and the terminal v1.9b. Once I tested the speed, eg 256 000 for ATMega32 and worked without a problem.

#include "stm32f10x.h"
#include "stm32f10x_conf.h"
void RCC_Conf(void);
int main(){
uint16_t zmienna =0;
     USART_InitTypeDef USART_InitStructure;
     GPIO_InitTypeDef GPIO_InitStructure;
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
/* Configure USART1 Tx (PA.09) as alternate function push-pull */
     GPIO_InitStructure.GPIO_Pin= GPIO_Pin_9;
     GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF_PP;
     GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
     GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */
     GPIO_InitStructure.GPIO_Pin= GPIO_Pin_10;
     GPIO_InitStructure.GPIO_Mode= GPIO_Mode_IN_FLOATING;
     GPIO_Init(GPIOA, &GPIO_InitStructure);
     USART_ClockInitTypeDef  USART_ClockInitStructure;
     USART_ClockInitStructure.USART_Clock= USART_Clock_Disable;
     USART_ClockInitStructure.USART_CPOL= USART_CPOL_Low;
     USART_ClockInitStructure.USART_CPHA= USART_CPHA_2Edge;
     USART_ClockInitStructure.USART_LastBit= USART_LastBit_Disable;
     USART_ClockInit(USART1, &USART_ClockInitStructure);
     USART_InitStructure.USART_WordLength= USART_WordLength_8b;
     USART_InitStructure.USART_StopBits= USART_StopBits_1;
     USART_InitStructure.USART_Parity= USART_Parity_No ;
     USART_InitStructure.USART_HardwareFlowControl= USART_HardwareFlowControl_None;
     USART_InitStructure.USART_Mode= USART_Mode_Rx | USART_Mode_Tx;
uint32_t tmp;
     tmp = USART1->CR1;
     tmp |= USART_InitStructure.USART_WordLength|USART_InitStructure.USART_Parity|USART_InitStructure.USART_Mode;
     USART1->CR1 = tmp;
     tmp = USART1->CR2;
     tmp |= USART_InitStructure.USART_StopBits;
     USART1->CR2 = tmp;
     tmp = USART1->CR3;
     tmp |= USART_InitStructure.USART_HardwareFlowControl;
     USART1->CR3 = tmp;
     USART1->BRR =(uint16_t)0x9c4;
/* Enable USART1 */
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE)== RESET){}
          USART_SendData(USART1, 0xA2);
          zmienna = USART_ReceiveData(USART1);
void RCC_Conf(void){
     ErrorStatus HSEStartStatus;
//reset ustawień RCC
//Włącz HSE
//Czekaj aż HSE będzie gotowy
     HSEStartStatus = RCC_WaitForHSEStartUp();
if(HSEStartStatus == SUCCESS){
//zwloka dla pamieci Flash
//PCLK1 = HCLK/2
//PLLCLK = 8MHz * 9 = 72MHz
          RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
//Włącz PLL
//Czekaj aż PLL poprawnie się uruchomi
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY)== RESET){}
//PLL będzie zrodlem sygnalu zegarowego