cancel
Showing results for 
Search instead for 
Did you mean: 

HRTIM burst DMA

JRyu.1
Associate

Hi,

I am trying to figure out to make HRTIM burst DMA working. I want to update timer period, compare1, compare2, and compare 3 registers by using burst DMA. There is not much information about this. There are two postings in the community posted several years ago, and it gave me some idea. But I need to have more information.

  • I used CubeMx to configure and generate code.
  • I want to trigger the burst DMA by software.
  • Assuming that the DMA source buffer data order matches to the order of number of registers to update, for there is no description stated in the reference manual.
  • Nothing happens when I run. It did not stop at burst DMA completion and DMA error callback function when I set breakpoints.

Below screenshots and code are used for the configuration.

0693W00000HqpNIQAZ.png0693W00000HqpMjQAJ.png 

0693W00000HqpMyQAJ.pngI am not sure that I need to check on the "Increment Address" or not.

InvPerComp[0] = new_per;    // new period
InvPerComp[1] = cmp1;       // new compare 1
InvPerComp[2] = cmp2;       // new compare 2
InvPerComp[3] = cmp3;       // new compare 3
 
// Will this update the registers in order?        
HAL_HRTIM_BurstDMATransfer(hrtim, timer, (uint32_t)&InvPerComp[0], 4)

0693W00000HqpNNQAZ.png

7 REPLIES 7
MTall.3
Associate II

Did you find a solution to this problem? It would be interesting to know as I'm working on a similar problem.

BKain.2
Associate II

Did you find a solution to this problem? I have a similar problem.

Pierre_Paris
ST Employee

Hello @JRyu.1 , @BKain.2 , @MTall.3 ,

Here some support and points that may help you :

  • Can you confirm you use HAL_HRTIM_BurstDMAConfig() to configure HRTIM burst DMA timer x update register (HRTIM_BDTxUPR) ? Please share register values before and after executing this line.

Pierre_P_2-1703003958669.png

  • Which STM32 are you using ?
  • Can you please share the HAL_HRTIM_MspInit() content ? Have you enable synchronization ? 

Best Regards,

Pierre

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.

liaifat85
Senior III

Confirm that the source buffer used for DMA holds the correct data in the correct order for updating the timer period, compare1, compare2, and compare3 registers.

Odiug
Associate

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

Odiug
Associate

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

Odiug
Associate

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