2023-04-24 08:14 AM - edited 2023-11-20 07:17 AM
Hello,
The CubeMX and the ST HAL has in the files "stm32XXxx_hal_conf.h" the
#define USE_HAL_USART_REGISTER_CALLBACKS
When I looking in the source code, there is no position to find where is this define used:
Searching for 'USE_HAL_USART_REGISTER_CALLBACKS'...
D:\Project\Core\Inc\stm32g4xx_hal_conf.h(108) : #define USE_HAL_USART_REGISTER_CALLBACKS 1U
Lines matched: 1 Files matched: 1 Total files searched: 130
In Activate this configuration with "USART" has no effect (CubeMx).
I think you can delete this define in all your HAL libraries and other software.
Best Regards, Markus
2023-04-25 02:11 AM
It's definitely used. Maybe not with your specific MCU model and STM32CubeMX version. It's used in stm32*_hal_uart.c and stm32*_hal_uart.h with all the MCUs I've used so far. CubeMX has to be compatible with many MCU models and library versions, so it certainly is possible there are unused settings. What's your MCU model and STM32CubeMX version?
2023-04-25 02:34 AM
2023-04-25 04:39 AM
USE_HAL_UART_REGISTER_CALLBACKS is used, but USE_HAL_USART_REGISTER_CALLBACKS isn't. UARTs, USARTs and LPUARTs use the same code(with checks like IS_LPUART_INSTANCE for the differences) so these callbacks are enabled for all of them or for none of them. They should have changed it so that if USE_HAL_UART_REGISTER_CALLBACKS or USE_HAL_USART_REGISTER_CALLBACKS is set to true that the callbacks are enabled. But they chose to ignore one of them. This is indeed a mistake by ST.
Use the other setting and it should work!