cancel
Showing results for 
Search instead for 
Did you mean: 

UART_DMA(LPUART) working oddly on STM32WB55

Kolab
Senior

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:

0693W00000Lvg9IQAR.pngWhat 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.

8 REPLIES 8
TDK
Guru

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.

https://github.com/STMicroelectronics/STM32CubeWB/blob/master/Drivers/STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_uart.c#L1422

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

If you feel a post has answered your question, please click "Accept as Solution".

@TDK​  I've updated the post. Sorry for the sorry for the inconvenience

Javier1
Principal

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

we dont need to firmware by ourselves, lets talk

I have just updated. But the problem persists.

what do you mean by "Line 1422 has nothing on it in the latest library, so you must be on a different version"?

Kolab
Senior

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.

BIsma.2
Associate

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

in my case it got working on its own :)