STM32 - How to trigger a DMA transfer via hardware timer, while CPU is in SLEEP mode?
So, I generated a standard CubeMX project. I used USART1 &amp; TIMER1.
hdma_tim1_up.Instance = DMA2_Channel2;
hdma_tim1_up.Init.Request = DMA_REQUEST_TIM1_UP;
hdma_tim1_up.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_tim1_up.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim1_up.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim1_up.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_tim1_up.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_tim1_up.Init.Mode = DMA_CIRCULAR;
hdma_tim1_up.Init.Priority = DMA_PRIORITY_LOW;
if (HAL_DMA_Init(&amp;hdma_tim1_up) != HAL_OK)
{
Error_Handler();
}

In the main function, after the initialization of the peripherals, I simply call
HAL_DMA_Start(htim1.hdma[TIM_DMA_ID_UPDATE], (uint32_t)&amp;testPWM, (uint32_t)&amp;huart1.Instance-&gt;TDR, 4);
__HAL_TIM_ENABLE_DMA(&amp;htim1, TIM_DMA_UPDATE);
HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
/* Infinite loop /
/ USER CODE BEGIN WHILE /
while (1)
{
/ USER CODE END WHILE /
__WFI();
/ USER CODE BEGIN 3 */
}

testPWM is a 4 byte array {0, 1, 2, 3}
The main loop is empty, no callbacks are used in code. The DMA controller sends 0 1 2 3 to the PC via UART, on each timer overflow event. When it reaches 3, it wraps back to 0.