cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 USART receive, When change baud rate not working

Tato
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tato
Associate II

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

 

View solution in original post

8 REPLIES 8

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
Up vote any posts that you find helpful, it shows what's working..

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);"

> 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

Tato
Associate II

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

 

1. Setting baud rate 9600 HTerm is working

Tato_0-1705281403369.png

 

 

2. Setting baud rate 56000 HTerm is working

Tato_1-1705281402919.png

 

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

Tato_2-1705281402643.png

 

Thank you.

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

Tato
Associate II

Anyone help me ?

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