2025-05-20 1:53 AM
Hi,
i am using STM32WBA55CG and i want:
1. wake-up from STOP mode to receive bytes over USART2 Rx
2. Handle data with half-complete and complete callback
3. Use the IDLE interrupt to detect the end of transmission
Each works perfectly on its own. However, when I try to combine both variants, the CPU hangs.
Since I cannot expect a specific byte length (1 byte could also be transferred as 100kB), I would like to process the data via a 1kB ring buffer. I can use half complete and complete callback for this. To recognize the end of the data transfer, I want to use the IDLE interrupt.
2025-05-20 4:38 AM
> Is it possible to combine USART2 Rx in autonomous DMA mode with IDLE mode?
Yes. The HAL_UARTEx_ReceiveToIdle with DMA in circular mode should do this.
> CPU hangs.
Debug, diagnose and fix.
2025-05-20 6:44 AM
I tried different variants, but could not use the DMA in autonomous mode together with IDLE mode.
HAL_UART_Receive_DMA(&huart2, dma_rx_buffer, 1024); // start UART2 Rx DMA
__HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE); //enable IDLE Interrupt
As shown in the graphic, I want to receive data of unknown length in the dma_rx_buffer. The buffer has a size of 1024 bytes and I start with HAL_UART_Receive_DMA.
After half of the data has been received, the CPU wakes up with a half complete callback. When 1024 bytes have been received, the complete callback is triggered and the DMA buffer is overwritten with the next byte at position [0]. If the data transfer is terminated after a total of 1124 bytes, the IDLE interrupt should be triggered here.
I start in UART Receive DMA mode and enable the IDLE interrupt, but the CPU hangs as soon i insert __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE); function.