cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474 re-trigger HAL_TIM_DMABurst_MultiWriteStart() from sw

CyberNerd
Associate III

Is it possible to re-trigger HAL_TIM_DMABurst_MultiWriteStart() from software? Currently it works only once (the first time) for me. Using TIM1 freq/duty-cycle:

HAL_TIM_DMABurst_MultiWriteStart(
   &htim1,
   TIM_DMABASE_ARR,              // Base = ARR
   TIM_DMA_UPDATE,               // Trigger = update event
   (uint32_t*)rampBurst,         // Source buffer
   TIM_DMABURSTLENGTH_3TRANSFERS,// ARR + RCR + CCR1
   N_STEPS*3                       // Number of bursts
);

__HAL_TIM_ENABLE_DMA(&htim1, TIM_DMA_UPDATE);

This produces a duty-cycle and frequency change over a certain amount of time, let's say 10ms, after the 10ms, I would like to disable the PWM output by setting the duty-cycle to 0:

__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, 0);

Then, I would like to re-trigger this each 100ms from software. My DMA setting is set to "Normal". The value of RCR is always 0 in the rampBurst array.

1 REPLY 1
Francois VILMAIN
ST Employee

Hello, 
Not sure it works but it might be worth trying this:

Once the first transfer is completed (triggered by hw) update the DMA transfer descriptor then re-start the DMA transfer when needed.

DMA descriptor update: replace DMA_REQUEST_TIM1_UP by DMA_REQUEST_MEM2MEM

Re-start DMA transfer: call HAL_DMA_Start_IT(htim1->hdma[TIM_DMA_ID_CC1], (uint32_t)ramBurst,
(uint32_t)&htim1->Instance->DMAR, DataLength)

Hope this helps.