cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_UART_RxCpltCallback never triggers

robotwhisperer
Associate

I am implementing a system with two STM32H753 microcontrollers. MCU1 reads ADC data and sends it over UART to MCU2 using UART DMA on ADC conversion. MCU2 reads data from UART via DMA and is supposed to do some filtering (among other things) to the received data. Earlier, all of the tasks were done by a single MCU (hence it was simpler, as we had access to the ADC data buffer already). 

The issue I am facing is that the UART Receive DMA is never triggering the HAL_UART_RxCpltCallback() callback no matter what I do. I have tried the same with UART_Receive_IT() with no results either. 

To help me ensure that it is not a configuration issue, I configured the same UART in a separate project (which is more of a simpler example of what I am trying to do) and verified my configuration to be working (posted about it earlier). 

10 REPLIES 10
Karl Yamashita
Principal

Did you enable the NVIC?

 

KarlYamashita_0-1757354754470.png

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.
TDK
Super User

Light on details here. Gotta be an issue somewhere. Wiring or code.

Here's an example of how to use HAL_UART_Receive_DMA that works:

STM32CubeH7/Projects/NUCLEO-H743ZI/Examples/UART/UART_TwoBoards_ComDMA/Src/main.c at fc00ae225a6bbc4f0838a45765c64bf8c4b20bee · STMicroelectronics/STM32CubeH7

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

NVIC is enabled, so is the DMA Stream interrupt. The configuration is the same as my other question I posted here.
That is supposed to be an isolated subset of the main project, but somehow when I put the changes from that minimal example into the main project they do not work. 

robotwhisperer_0-1757355657638.png

 

bmckenney
Associate III

Are you still using 1-byte transfers? (You mentioned something about sending ADC readings.)

The (Rx) DMA won't complete until it transfers the length you requested, so the other side has to send exactly that many.

A key setting in the example TDK mentioned:

> #define RXBUFFERSIZE TXBUFFERSIZE

Currently still using 1-byte transfers, yes. Once I get the UART Callback working correctly I will update the sizes to be the appropriate size (18 bytes for 9 16-bit ADC values in my case). 

My receiving side looks something like: 

  auto status = HAL_UART_Receive_DMA(huart3_, rx_buffer_.data(), 1);

And the sending side looks like:

  HAL_UART_Transmit_DMA(huart3_, data, 1);


Additionally, I did check the UART TX pin on the sender side with an oscilloscope and it does indeed send the byte as expected. 

gbm
Principal

Double-check the spelling of routine's name. Or - better yet - copy the name from the header file or HAL manual.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Thanks for the suggestion, I did copy the function name from the HAL file in the project, so I am sure it is not something like a typo somewhere. 

TDK
Super User

> but somehow when I put the changes from that minimal example into the main project they do not work. 

So probably an issue with the integration then. Perhaps an overrun.

Debug the program. When it "doesn't work", hit pause an examine the state of the huart handle and relevant UART/DMA registers.

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

Thanks for pointing that out. When I debug, I set a breakpoint on the HAL_UART_RxCpltCallback which is never hit. I added a live expression so that I can see the state of the uart handle while the project runs. Here is what I am seeing

robotwhisperer_0-1757360690131.png


I see that the error code is 0, which is good, since it means no error. However, the gState and RxState are non-zero, and I could not find a definition for them in the generated code. I think this might be important?