2022-03-24 03:20 PM
Hello, I have been trying to send and receive data through UART using DMA on STM3WB55. Everything was working properly but suddenly HAL_UART_Transmit_DMA started to work unproperly: the program gets stuck in the Hard Fault function. I am calling HAL_UART_Transmit_DMA inside the function HAL_UART_RxCpltCallback. When I call it in the while loop in the main.c file, the program works good. My buffers are 71 and 273 long. Later I tried HAL_UART_Transmit and HAL_UART_Transmit_IT inside HAL_UART_RxCpltCallback but none of them works anymore. When I comment this line, the program works good.
I attached the main.c , stm32wbxx_it.c and usart.c files.
Here is the call stack untill it falls into the hard fault function:
What I want to do is to send data after the reception is complete. The reception through HAL_UART_Receive_DMA seems to be correct. Just the transmit. Any clue? Thank you.
2022-03-24 03:37 PM
Would be helpful to see the complete code. Where is the definition of res?
Line 1422 has nothing on it in the latest library, so you must be on a different version.
The code you've posted won't even compile since the brackets are unbalanced.
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){
if(huart==&hlpuart1)
state = HAL_UART_Transmit_DMA(&hlpuart1,(uint8_t*)res,(uint16_t)NMEA_COORD_LEN);
}
}
2022-03-25 12:47 AM
@TDK I've updated the post. Sorry for the sorry for the inconvenience
2022-03-25 01:13 AM
Did you just Updated stm32cubeIDE to version 1.9.0?
I had problems because they changed the compiler to gcc10, it gave me similar problems
2022-03-25 05:22 AM
I have just updated. But the problem persists.
2022-03-27 02:05 AM
what do you mean by "Line 1422 has nothing on it in the latest library, so you must be on a different version"?
2022-03-28 03:58 AM
I finally made it work. I had just to change the length of my buffer from 71 to 70 or 72 and it started working properly. I'm not sure if DMA sympathize more with even lengths.
2023-03-01 06:19 AM
How did you manage to make LPUART1 working in the first place. i wrote a simple code that transmit a char evry 500 Ms and it wont work
2023-03-07 02:13 PM
in my case it got working on its own :)