Skip to main content
Visitor II
July 25, 2025
Question

Update MPER register with every HRTIM period

  • July 25, 2025
  • 3 replies
  • 395 views

I am also failing in reproducing the DMA example from https://wiki.st.com/stm32mcu/wiki/Getting_started_with_HRTIM#To_go_further_about_DMA_burst.

HAL_HRTIM_BurstDMAConfig() is mentioned in the text, but not present in the code example. Did you miss to put it into the example?

 

Minor issue: I find it weird to edit HAL_HRTIM_MspInit() to change DMA_MEMORY_TO_PERIPH to DMA_MEMORY_TO_MEMORY as this gets overwritten by the next code generation.

Would it be safe to put this in the user section below:

 /* USER CODE BEGIN HRTIM1_MspInit 1 */
 hdma_hrtim1_a.Init.Direction = DMA_MEMORY_TO_MEMORY;

 if (HAL_DMA_Init(&hdma_hrtim1_a) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE END HRTIM1_MspInit 1 */

This would result calling HAL_DMA_Init() twice. Is this OK?

 

Kind regards,

Guido

    This topic has been closed for replies.

    3 replies

    OdiugAuthor
    Visitor II
    July 25, 2025

    Sorry, I was wrong. HAL_HRTIM_BurstDMAConfig() is called in the autogenerated MX_HRTIM1_Init().

    OdiugAuthor
    Visitor II
    July 25, 2025

    What I would like to achieve in the end is a running HRTIM1 where the MPER register gets updated with every period. I assumed this can be achieved with burst DMA.

    The example from https://wiki.st.com/stm32mcu/wiki/Getting_started_with_HRTIM#To_go_further_about_DMA_burst is the only one, I could find.

    In order to learn more about burst DMA, I started experimenting. First, I wanted to update multiple registers.

    I am writing to the four CMP registers and preset them with different values to visualize it better:

    static uint32_t reg_update[] = {
    		0xaaaa,
    		0xbbbb,
    		0xcccc,
    		0xdddd,
    };
    
    static inline void BurstDMA_Test(void)
    {
    	HAL_StatusTypeDef ret;
    
    	HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CMP1xR = 0x11;
    	HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CMP2xR = 0x22;
    	HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CMP3xR = 0x33;
    	HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CMP4xR = 0x44;
    
    	ret = HAL_HRTIM_BurstDMATransfer(
    			&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, (uint32_t)reg_update, 4);
    	if (ret != HAL_OK)
    	{
    	 Error_Handler();
    	}
    }

     But that just gave me:

    Odiug_0-1753453836062.png

    So, the first value is copied into all the configure registers.

    OK, so maybe I have to set the "Increment Address" for the DMA configuration:

    Odiug_1-1753453952541.png

    But this results in only one register being updated:

    Odiug_2-1753454109872.png

    I am puzzled!

    So, my first piece in understanding would be: How to update multiple registers from a single buffer.

     

    Kind regards,

    Guido

    ST Employee
    August 15, 2025

    This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

    Regards,
    Christian