cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 Baudrate Fault

karatepe101
Associate II
Posted on November 12, 2015 at 09:06

Hi,

I am using STM32F072C8 uC and i configrated USART1 as 9600 bps. When I was sending some data,i don't receive correctly any data(when my serial port program set 9600bps).But i change my program baudrate as 14400bps and its work. My code ;

USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
SystemCoreClockUpdate();
// ***
SysTick_Config(SystemCoreClock / 1000);
// ***
syscore=SystemCoreClock;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
/* Configure USART1 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 9600;
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;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1,ENABLE);

2 REPLIES 2
karatepe101
Associate II
Posted on November 12, 2015 at 11:25

I fixed this fault.I was change HSE value as 12MHz and works now.

Nesrine M_O
Lead II
Posted on November 12, 2015 at 11:40

Hi tunder.pinyin,

Thank you for posting your findings and how you fixed the issue, it is good to hear that it was solved. 

-Syrine-