'STM32L476RG HAL_UARTEx_RxEventCallback never call
I'm curently working on a projet with a STM32F334 and a STM32L476RG and I have a problem to making them talking with eachother. I'm using a DMA global interrupt like explained here.
I noticed a difference into the 'main.c' of my both projects:
- With the F334:
MX_DMA_Init()is done beforeMX_USART2_UART_Init() - With the L476RG: It's the opposite.
I tryed to inverse them and it works but only once... (at start)
So how could I tell the code generator to initialize the DMA before my USART2?
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t size) {
if (huart->Instance == USART2) {
rs485_send_data(huart, g_rs485Input, size);
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, g_rs485Input, RS485_INPUT_LENGTH);
__HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);
}
}
Solution 1:[1]
I has experimented same issue. I build the same example for NUCLEO-L073RZ but at first, the function HAL_UARTEx_RxEventCallback was never called.
Then I read your question, and I set the order as You say
MX_DMA_Init() before MX_USART2_UART_Init()
(like in the controllerstech example). I reset the uart transmisor and debug again NUCLEO board.Then I had one breakpoint in HAL_UARTEx_RxEventCallback, so the program entered into the function an was stoped in the breakpoint. AS you say, the program enter in the breakpoint once in ever start.
So, I tried deleting this breakpoint in order to do not stop the program in debugging. After that, I watch in Live Expressions MainBuf, RxBuf, isOK, oldPos, newPos and it seems that is working perfectly.
Has you tried without breakpoints? Another way, you can try not debugging, running the program in normal mode and verify turning on one led or writing in other uart port.
Is not the first time that I have experienced irregular running of the program in debug mode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Javi Guembe |
