cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 Uart Byte Received error(higher4bit)

jhl14
Associate II

Hi,

Using "STM32F4xx_DSP_StdPeriph_Lib_V1.8.0" to config STM32F407 Uart1 as following

///////////////////////////////////////////////////////////////////////////

void USART1_Init(u32 baudrate)

{

USART_InitTypeDef USART_InitStructure;

GPIO_InitTypeDef GPIO_InitStructure;

/* Step 1 enable the clock of USART1 and GPIO */

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_USART1);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; 

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_USART1);

USART_InitStructure.USART_BaudRate = baudrate;

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_ITConfig(USART1, USART_IT_RXNE, ENABLE);

USART_ClearITPendingBit(USART1,USART_IT_CTS|USART_IT_LBD|USART_IT_TC|USART_IT_RXNE);

USART_Cmd(USART1, ENABLE);

USART_ClearFlag(USART1, USART_FLAG_TC);

}

////////////////////////////////////////////////////////////////////////////////

At the Pin RX of STM32F407 , capture the correct data written down by the host as following chart show

0693W000008x1SVQAY.pngBut got the following bytes content in the Rxbuffer

0693W000008x1R3QAI.png

even in the memory location, the data in the DR reg is 0xC8 for the 3rd byte received, not 0xA8 shown at the pin's wave.

0693W000008x1TEQAY.png

Thank you for any thoughts!

BRs,

JH​

1 ACCEPTED SOLUTION

Accepted Solutions
jhl14
Associate II

This LOW LEVEL error is resolved by changing the HSE_VALUE to 8000000HZ。

 #if !defined (HSE_VALUE) 

 #define HSE_VALUE  ((uint32_t)8000000) /*!< Value of the External oscillator in Hz(25000000 default value) */

 #endif /* HSE_VALUE */

View solution in original post

1 REPLY 1
jhl14
Associate II

This LOW LEVEL error is resolved by changing the HSE_VALUE to 8000000HZ。

 #if !defined (HSE_VALUE) 

 #define HSE_VALUE  ((uint32_t)8000000) /*!< Value of the External oscillator in Hz(25000000 default value) */

 #endif /* HSE_VALUE */