🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-embedded-software › how-to-use-hal-registercallback-to-register-an-object-method-c › td-p › 709685
Solved: How to use HAL_*_RegisterCallback to register an o... - STMicroelectronics Community
August 16, 2024 - void HAL_UARTEx_RxEventCallbac... uc->RxEventCallback_(Size); } If understand correctly, the HAL provides HAL_*_RegisterCallback, which would allow a similar registration directly....
🌐
St
dev.st.com › stm32cube-docs › stm32u5-hal2 › 2.0.0-beta.1.1 › docs › drivers › hal_drivers › uart › hal_uart_how_to_use.html
HAL UART How to Use — HAL STM32U5XX 0.1.0 documentation
If required, program UART advanced features (TX/RX pins swap, auto baud rate detection,…) with a set of different configuration functions. When the compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 1U, the user can dynamically configure the driver callbacks, via its own method:
Discussions

STM32 uart callback in c++ - Stack Overflow
maybe it's a stupid question, but I am in a process of porting a c code in c++ for the stm32. In c I was using this instruction to detect interrupts on the uart channel: HAL_UART_RegisterCallback(&... More on stackoverflow.com
🌐 stackoverflow.com
how to register separate callback function for each UART port in stm32 - Stack Overflow
I am using Freertos to program in STM32. is it possible to register separate callback function for each UART port in stm32? Whenever data received in that port that particular callback function has... More on stackoverflow.com
🌐 stackoverflow.com
hal library - STM32 HAL Implementing UART receive Interrupt - Electrical Engineering Stack Exchange
I have trouble in implementing the USART RX on a stm32f303k8t6 with the HAL libraries. What I actually want to achieve is, that I can send a variable length string over the uart bus and decode the ... More on electronics.stackexchange.com
🌐 electronics.stackexchange.com
September 30, 2017
STM32 HAL UARTEx_ReceiveToIdle_DMA: USART IDLE IRQ fires but never calls RxEventCallback
i used HAL_UART_TxCpltCallback to notify my program that a uart tx via DMA has been completed. i grepped and there is also a version for Rx. maybe you can try to use this callback to see if it works More on reddit.com
🌐 r/embedded
2
0
July 10, 2025
🌐
STMicroelectronics Community
community.st.com › stmicroelectronics community › resources › knowledge base › stm32 mcus › how to use register callbacks in stm32
How to use register callbacks in STM32 | Community
August 11, 2023 - HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback)
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus › faq-stm32-hal-uart-driver-api-and-callbacks › ta-p › 49301
FAQ: STM32 HAL UART driver - API and callbacks - STMicroelectronics Community
February 18, 2026 - In transmit direction, the DMA TC event is triggered when the last data has been written to the UART data register but not yet fully transmitted out of the UART (The TC event is triggered by the DMA). In circular buffer mode, the HAL_UART_TxCpltCallback is called from the HAL_DMA_IRQHandler.
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › registering-a-user-callback-for-usart-on-stm32l4s5zi › td-p › 225901
Solved: Registering a User callback for USART on STM32L4S5... - STMicroelectronics Community
March 14, 2021 - My question is whether the argument for the callback function has to be compulsorily (struct __UART_HandleTypeDef *huart)? because in UART_DMATransmitCplt() function it knows that the event received is DMA Transfer Complete and so it checks if huart->TxCpltCallback is populated or else it executes the weak function as can be see below · #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) /*Call registered Tx complete callback*/ huart->TxCpltCallback(huart); #else /*Call legacy weak Tx complete callback*/ HAL_UART_TxCpltCallback(huart); #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
Find elsewhere
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-embedded-software › stm32u535-hal-uart-wake-up-register-callback-missing › td-p › 725637
Solved: STM32U535 HAL UART Wake-up register callback missi... - STMicroelectronics Community
October 4, 2024 - Hi @lgacnik97 On STM32U5xx serie, there's no WakeupCallback (no WUF/WUS settings). So UART_HandleTypeDef type definition is correct. On the other hand, the value HAL_UART_WAKEUP_CB_ID could then be removed from HAL_UART_CallbackIDTypeDef enumeration, for clarity's sake.
🌐
Reddit
reddit.com › r/embedded › stm32 hal uartex_receivetoidle_dma: usart idle irq fires but never calls rxeventcallback
r/embedded on Reddit: STM32 HAL UARTEx_ReceiveToIdle_DMA: USART IDLE IRQ fires but never calls RxEventCallback
July 10, 2025 -

Title:
STM32 HAL UARTEx_ReceiveToIdle_DMA: USART IDLE IRQ fires but never calls RxEventCallback (DMA TC preempts?)

Body:

Hi everyone,

I’m using an STM32 (F4/F7) in half-duplex + data-inverted mode with the HAL extended API:

HAL_UARTEx_ReceiveToIdle_DMA(&huart1, dma_buf, 64);

My callback looks like:

void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
    // copy Size bytes from dma_buf into my ring buffer…
    HAL_UARTEx_ReceiveToIdle_DMA(huart, dma_buf, 64);
}

Observed behavior:

  1. USART1_IRQHandler fires on IDLE → runs HAL_UART_IRQHandler(&huart1)

  2. Immediately after, DMA2_Stream2_IRQHandler fires → runs HAL_DMA_IRQHandler(&hdma_usart1_rx)

  3. HAL_UARTEx_RxEventCallback never runs, so no data gets processed

What I’ve checked:

  • Callback signature matches the HAL’s weak declaration

  • Swapped NVIC priorities (USART1 IRQ vs. DMA2_Stream2 IRQ) and even disabled the DMA IRQ

Debug video:
Watch the step-through on YouTube

Questions:

  • Does USART1_IRQn have to be higher priority than DMA2_Stream2_IRQn for RxEventCallback to fire?

  • Any hidden HAL state or flags I’ve missed?

  • Has anyone successfully combined half-duplex + data-invert + ReceiveToIdle_DMA on STM32?

Thanks in advance for any tips!

🌐
Stack Overflow
stackoverflow.com › questions › tagged › uart
Highest scored 'uart' questions - Page 25 - Stack Overflow
July 4, 2022 - maybe it's a stupid question, but I am in a process of porting a c code in c++ for the stm32. In c I was using this instruction to detect interrupts on the uart channel: HAL_UART_RegisterCallback(&...
Top answer
1 of 9
2
Posted on August 06, 2014 at 15:04 · Hih.hammer, · Let's shed some light onhow the interrupt handlers work for the HAL UART module: · When the HAL_UART_RxCpltCallback() API is called the UART module is ready for another receive, so user can start the next receive process under the call back API. · Before starting the next receive operation, make sure the DR register is empty (no data received on the UART interface after the last DR register read) to avoid UART overrun error: you can use this macro to flush the DR register: __HAL_UART_FLUSH_DRREGISTER() · Concerning the use of the UART to receive various console like commands (each different in length), it depends on application constratins: · For blocking mode, you can use the polling process by configuring the parameter size as max commands size and the parameter Timeout as max commands timeout and check the process returned status: if the status is HAL_TIMEOUT but the data is correctly received in this case you can consider that the transfer is done with success then you can start the second receive process. · UARTStatus = HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, MaxCmdSize, MaxCmdTimeout); · /* MaxCmdSize and MaxCmdTimeout depend on user application */ · While(UARTStatus != HAL_OK) || (UARTStatus != HAL_TIMEOUT)) · { · HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, MaxCmdSize, MaxCmdTimeout); · } · For non-blocking mode (IT or DMA), it should be better to do this in two receive operations instead of single byte at a time: you can start the first receive processto ger the command opcode (I think that the opcode size is fix) and when the opcode is received under the callback you can decode the data and start the second receive process to receive that command body. · Thank you for your interest in our STM32Cube solution. · With regards.
2 of 9
0
Posted on November 28, 2014 at 07:52 · Heisenberg, · I have question along same lines.  · A little background will help you understand my questions: · I have an application written for an NXP ARM7 I'd like to port to STM32F4. The ARM7 is a component in a system that includes a host PC running high level control code. · The ARM7 has a 16 byte receive buffer in the UART that is completely hands free, transparent to the user. User code has a long (500us) high priority (time sensitive) scheduled routine that runs every mS, that doesn't(can't) get interrupted so the host PC never sends a string longer than the 16 byte UART buffer. The buffer allows saving characters during the scheduled routine without causing a timing deviation in that routine. The ARM7 code uses polling (blocking) when it's ready to see what next command is, and the command is always terminated with a CR so it pulls one byte at a time from the buffer until it finds the CR. If the scheduled routine starts during the polling process, the polling of course resumes once the routine is complete. The length of the command is variable. · For the STM  · HAL_UART_Receive() command I have a couple questions to see if this blocking command can work in my situation. · 1 - once the  · HAL_UART_Receive() starts, if the high priority (uninterruptable) scheduled routine is called, will overruns occur if characters are received while scheduled routine is using processor? - I guess I'm asking if this blocking routine is using DMA in the background and can buffer data without the using the processor. · 2 - for the timeout that is part of the  · HAL_UART_Receive(), does the timeout start at the moment the API is called, or does it start when the 1st byte arrives at the UART? Since I don't know the length of command, I can use a timeout to return from API but only if the timeout doesn't start until the 1st character arrives at the UART. The UART runs at 200,400 baud and some of the commands take less than a mS to complete, but the host computer can take anywhere from 1mS to 10mS to respond to a request for next command. Excessive timeout waits will add-up and cause unacceptable throughput loss. · With the command length unknown, is there a documented way to use DMA for this task? · Thanks in advance for any help you can provide. · -Billy
🌐
STMicroelectronics Community
community.st.com › t5 › stm32-mcus-products › hal-uart-rxcpltcallback-not-being-called-for-usart1-and-usart1 › td-p › 602605
HAL_UART_RxCpltCallback not being called for USART1 and USART1_IRQHandler has no data
November 1, 2023 - Selecting "register callback" means, that you have to write code registering your own functions. The traditional way is not selecting that in which case you have to implement your own HAL_UART_RxCpltCallback (what yo did).
🌐
SysProgs
sourcevu.sysprogs.com › stm32 › HAL › symbols › HAL_DMA_RegisterCallback
HAL_DMA_RegisterCallback() - syntax, references, description
DMA UART Rx communication abort callback, when initiated by user by a call to HAL_UART_AbortReceive_IT API (Abort only Rx transfer) (This callback is executed at end of DMA Rx Abort procedure following user abort request, and leads to user Rx Abort Complete callback execution).
🌐
Infineon
infineon.github.io › psoc6hal › html › group__group__hal__uart.html
UART (Universal Asynchronous Receiver-Transmitter)
High level interface for interacting with the Universal Asynchronous Receiver-Transmitter (UART).