cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestion for TIM_DMABurst_WriteStart()

Lecordier.Guy
Associate III
Posted on August 04, 2016 at 12:07

  Dear,

I want to generate the 4 signals for a H bridge to create a sinusoidal signal by pwm

So I used Timer 1 and its 4 channels powered by a DMA in burst mode

 The PWM data are organized in an array of 360 structures

 {

 {CCR1, CCR2, CCR3, CCR4},

 …

 {CCR1, CCR2, CCR3, CCR4},

 }

 

 I wanted to start by HAL_TIM_DMABurst_WriteStart() but I found this function not enough flexible as the same variable (BurstLength) is used to program:

 the number of data to transfer in the DMA_SxNDTR register

  /* Enable the DMA Stream */

  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U);    

 and the DMA burst length in the TIM1_DCR timer   

  /* configure the DMA Burst Mode */

  htim->Instance->DCR = BurstBaseAddress | BurstLength; 

  I think it should be different; in my case

  /* Enable the DMA Stream */

  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, 360*4;     

  /* configure the DMA Burst Mode */

  htim->Instance->DCR = BurstBaseAddress | TIM_DMABURSTLENGTH_4TRANSFERS; 

 In final

  HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,

                                              uint32_t* BurstBuffer, uint32_t  BurstLength)

 should be

 

  HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,

                                              uint32_t* Buffer, uint32_t  BufferLength,

                                              uint32_t  BurstLength)

 My platform is STM32F429 Cube_FW_F4_V1.12.0

Regards

1 REPLY 1
slimen
Senior
Posted on August 31, 2016 at 16:31

Hi,

Maybe you can insprire from TIM examples within STM32CubeF4 package and implement your code, like this example which shows how to update the TIM1 channel1 period and the duty cycle using the TIM1 DMA burst mode:

STM32Cube_FW_F4_V1.13.0\Projects\STM324xG_EVAL\Examples\TIM\TIM_DMABurst

Regards