2022-01-15 09:25 AM
I am trying to receive messages in DMA mode, on a STM32L432KCU. The pins PA2 and PA3 are configured as DMA pins. The baudrate is 115200 and the global interrupt for USART2 is turned on. In the main function, I have the initialization of the peripherals:
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_DMA_Init();
, which is followed by the functions that turn on the idle receive mode of the DMA and disable the half transfer interrupt:
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, UART2_rxBuffer, 12);
__HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);
Here I have the callback:
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){
if(huart->Instance == USART2){
memcpy(mainbuff, UART2_rxBuffer, Size);
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, UART2_rxBuffer, 12);
__HAL_DMA_DISABLE_IT(&hdma_usart2_rx, DMA_IT_HT);
}
}
It checks if the message is received from the second uart, then copies it into the main buffer, that stores all the data. The receive is enabled again and the half transfer interrupt is disabled. Unfortunately, when I am trying to debug, the breakpoint inside the callback never gets hit. I've also tried to display the message. It didn't work. What could cause this problem?
2022-01-15 12:31 PM
Init DMA before UART.
2022-01-15 11:10 PM
Thank you! I will try.
2022-01-19 06:59 AM
Hello @Stefan.Andon ,
Did you tried @TDK's proposal ? Does it work ?
If yes, please mark his reply as Best answer (click on "Select as Best"). This will help other users find that answer faster.
Thanks
Imen
2022-01-20 06:36 AM
Hi, @Imen DAHMEN ,
Unfortunately, I was not able to test @ TDK's solution, as I don't have the hardware with me at the moment. I will respond as soon as I try.
2022-01-28 03:54 AM
Hello,
Unfortunately it didn't solve the problem
2022-01-28 04:08 AM
Polled UART Rx works?
DMA works?
Some interrupt-related hints here.
Read out and check/post UART and DMA registers content, after having some data arrived at the Rx pin.
JW
2022-01-28 05:21 AM
The pins PA2 and PA3 are configured as DMA pins" -- This makes no sense. DMA transfers do not occur at the SoC pins. The DMA transfers are between the main memory and the RX & TX data registers of the UART's host interface.