2017-11-02 07:59 PM
I am trying to use the HAL timer PWM DMA to implement something similar the TIM_DMABurst example in the STM32xG_EVAL directory but for more than 1 waveform.
The TIM_DMA example in the STM32CubeMx STM32xG_EVAL directory only changes the duty cycle via DMA keeping the same frequency and repetition count for three different duty cycles.
The TIM_DMABurst example in this same directory sets the PWM frequency, repeat count and duty cycle for a single wave form.
Is there a way to accomplish both together in a single HAL call.
For example:
uint32_t ClockSpeed = HAL_RCC_GetHCLKFreq() / 2;
uint32_t WaveForm[ 9 ] =
{
ClockSpeed / 38000, // 38kHz Frequency
10, // 10 cycles
( ClockSpeed / 38000 ) / 2, // 50% duty cycle
ClockSpeed / 30000, // 30kHz Frequency
25, // 25 cycles
( ClockSpeed / 30000 ) / 3, // 33% duty cycle
ClockSpeed / 45000, // 45kHz Frequency
15, // 10 cycles
( ClockSpeed / 45000 ) / 4, // 25% duty cycle
};
How do I use HAL_TIM_PWM_Start_DMA() and/or HAL_TIM_DMABurst_Start() to generate the kind of waveform described in the above array.
In the Arbitrary waveform generation using timer DMA-burst feature section (5.3) of the General Purpose timer cook book (AN4776) shows partially how to set this up by writing directly to the registers but it does not use the HAL.