Skip to main content
Associate
January 12, 2024
Solved

STM32F407 USART receive, When change baud rate not working

Hello.

I'm using STM32F407, use usart3 set DMA setting baud rate 9600 and use receive 

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)

{

if (huart->Instance == USART3) {

HAL_UARTEx_ReceiveToIdle_DMA(&huart3, RxBuff, Size);

__HAL_DMA_DISABLE_IT(&hdma_usart3_rx, DMA_IT_HT);

}

}

 

connect to computer using software terminal "HTerm"

 

Set baud rate 9600 STM32F407 can receive

But i change to other baud rate such as 115200

then i change baud rate 9600 can not receive

This topic has been closed for replies.
TatoBest answer
Associate
January 15, 2024

1. Setting baud rate 9600 HTerm is working

STM32_1.png

 

2. Setting baud rate 56000 HTerm is working

STM32_2.png

3. Setting came back  baud rate 9600 HTerm is not working

STM32_3.png

 

8 replies

Tesla DeLorean
Guru
January 12, 2024

Check if you have any sticky errors in the status register that need clearing.

ie noise, framing, parity, overrun, etc

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TatoAuthor
Associate
January 12, 2024

I'm Setting USART3 below

static void MX_USART3_UART_Init(void)

{

huart3.Instance = USART3;

huart3.Init.BaudRate = 9600;

huart3.Init.WordLength = UART_WORDLENGTH_8B;

huart3.Init.StopBits = UART_STOPBITS_1;

huart3.Init.Parity = UART_PARITY_NONE;

huart3.Init.Mode = UART_MODE_TX_RX;

huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart3.Init.OverSampling = UART_OVERSAMPLING_16;

if (HAL_UART_Init(&huart3) != HAL_OK)

{

Error_Handler();

}

}

I ever clearing below

"__HAL_UART_CLEAR_PEFLAG(&huart3);"

"__HAL_UART_CLEAR_FEFLAG(&huart3);"

"__HAL_UART_CLEAR_NEFLAG(&huart3);"

"__HAL_UART_CLEAR_OREFLAG(&huart3);"

"__HAL_DMA_DISABLE_IT(&hdma_usart3_rx, DMA_IT_HT);"

"__HAL_UART_CLEAR_FLAG(&huart3, UART_IT_IDLE);"

"__HAL_UART_ENABLE_IT(&huart3, UART_IT_RXNE);"

waclawek.jan
Super User
January 12, 2024

> then i change baud rate 9600 can not receive

How do you change baud rate?

Read out content of UART registers for "working" and "not working" cases, and compare/post.

JW

TatoAuthor
Associate
January 15, 2024

1. Setting baud rate 9600 HTerm is working

Tato_3-1705281438954.png

 

 

2. Setting baud rate 56000 HTerm is working

Tato_4-1705281438955.png

 

3. Setting came back  baud rate 9600 HTerm is not working

Tato_5-1705281438956.png

 

Thank you

TatoAuthorBest answer
Associate
January 15, 2024

1. Setting baud rate 9600 HTerm is working

STM32_1.png

 

2. Setting baud rate 56000 HTerm is working

STM32_2.png

3. Setting came back  baud rate 9600 HTerm is not working

STM32_3.png

 

TatoAuthor
Associate
January 22, 2024

Anyone help me ?

Andrew Neil
Super User
January 22, 2024

You've marked your post of ‎2024-01-14 05:16 PM as the Solution - did you not mean to do that?

AndrewNeil_0-1705922061760.png

AndrewNeil_0-1705922264677.png

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.