2025-07-17 7:31 AM - edited 2025-07-18 1:01 AM
Dear reader,
I attempted to adapt the tutorial outlined in STM32F3348-DISCO HRTIM DMA PWM Sine Wave - STMicroelectronics Community to my STM32G474E-DPOW1 board to create a PWM signal with sinusoidally varying duty cycle using a look up table.
Attached is my main.c with the MX_HRTIM1_Init function. If there's any more information required please let me know
Any help would be greatly appreciated, thankyou
Oliver
2025-07-18 3:55 AM
Hello @Oli98;
Could you please refer to Getting started with HRTIM - stm32mcu wiki and get inspired to create your own project. This wiki helps you learn about HRTIM and provides a simple application to create a single PWM.
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-07-21 3:55 AM - edited 2025-07-22 2:52 AM
Hi Kaouthar,
I began trying to adapt this example from https://wiki.st.com/stm32mcu/wiki/Getting_started_with_HRTIM for the burst dma mode section by changing the reg_update as follows:
static uint32_t Reg_Update [] =
{
PERIOD/16, PERIOD/8, PERIOD/4, PERIOD/2, PERIOD,
};
I also changed HAL_HRTIM_MspInit as per the tutorial and updated as follows for continuous dma updates:
hdma_hrtim1_a.Instance = DMA1_Channel1;
hdma_hrtim1_a.Init.Request = DMA_REQUEST_HRTIM1_A;
hdma_hrtim1_a.Init.Direction = DMA_MEMORY_TO_MEMORY;
hdma_hrtim1_a.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_hrtim1_a.Init.MemInc = DMA_MINC_ENABLE;
hdma_hrtim1_a.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_hrtim1_a.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
hdma_hrtim1_a.Init.Mode = DMA_CIRCULAR;
hdma_hrtim1_a.Init.Priority = DMA_PRIORITY_LOW;
2025-07-31 8:48 AM
I am stuck trying to do the same thing. Tutorial works fine but not when doing the period
I am just trying to update the period
uint32_t Reg_Update [] =
{
59999
};
if(HAL_HRTIM_BurstDMATransfer(&hhrtim, HRTIM_TIMERID_TIMER_B, (uint32_t) Reg_Update, sizeof(Reg_Update)/sizeof(uint32_t)) != HAL_OK) //Add a breakpoint here
{
Error_Handler();
}
I am able to do the Compare 1 reg just like the tutorial, but I cannot do it for the period.