2025-06-27 2:56 AM
I'm able to generate a simple PWM signal but I wasn't able to generate arbitrary waveform with DMA (HAL_TIM_DMABurst_MultiWriteStart).
How should be configured the DMA ?
Is there an example that use PWM with DMA on STM32U5 ?
2025-06-27 3:26 AM - edited 2025-06-27 3:28 AM
Hello @nicolas
Please refer to the application note AN4776 to generate arbitrary waveform with DMA.
Also see the article below:
Custom Signal generation using PWM and DMA - STMicroelectronics Community
2025-06-27 3:49 AM
Thanks for the reply. I have already looked at this document but it's old (2019) so it doesn't account of the new GPDMA found in STM32U5. It also directly access register instead of using the HAL (does ST recommend to not use HAL ?).
The article also don't use GPDMA.
2025-06-27 4:24 AM
I'm now able to use HAL_TIM_PWM_Start_DMA() with GPDMA configured with SrcDataWidth = DMA_SRC_DATAWIDTH_BYTE;
But it's only works with byte, so it's very limitative for a 16 bits timer.
2025-06-27 5:39 AM
I'm now able to use HAL_TIM_DMABurst_MultiWriteStart with full resolution.
For working with 32 bits data, GPDMA need to have DataAlignment = DMA_DATA_PACK;
DataLength of HAL_TIM_DMABurst_MultiWriteStart should be in byte length.
I still have a problem with ARR value that are shifted (first portion use 2nd ARR value ...)
NodeConfig.NodeType = DMA_GPDMA_LINEAR_NODE;
NodeConfig.Init.Request = GPDMA1_REQUEST_TIM1_UP;
NodeConfig.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
NodeConfig.Init.Direction = DMA_MEMORY_TO_PERIPH;
NodeConfig.Init.SrcInc = DMA_SINC_INCREMENTED;
NodeConfig.Init.DestInc = DMA_DINC_FIXED;
NodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_BYTE;
NodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_WORD;
NodeConfig.Init.SrcBurstLength = 1;
NodeConfig.Init.DestBurstLength = 1;
NodeConfig.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT0;
NodeConfig.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
NodeConfig.Init.Mode = DMA_NORMAL;
NodeConfig.TriggerConfig.TriggerPolarity = DMA_TRIG_POLARITY_MASKED;
NodeConfig.DataHandlingConfig.DataExchange = DMA_EXCHANGE_NONE;
NodeConfig.DataHandlingConfig.DataAlignment = DMA_DATA_PACK;
2025-06-27 6:11 AM
Hello @nicolas
Could you share your code please ?
2025-06-27 6:16 AM
2025-06-27 7:12 AM
Hello @nicolas
Could you please check the status of the update event flag before starting the DMA brust.
2025-06-27 8:45 AM
UIF is set after calling HAL_TIM_PWM_Start() and before HAL_TIM_DMABurst_MultiWriteStart()