2018-07-04 01:56 PM
I am doing now small project with STM32F0. I would like to generate two PWM signals simultaneously using DMA. Everything is working fine if I am starting one of two PWM Generators. When I start two works only first one. Is there a way to make this PWM generation simultaneous on two channels?
Code simply looks like this:
HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_1, buf1, 6);
HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_4, buf2, 6);2019-01-23 06:26 AM
It is possible, but to start another PWM need a lot of time to wait after first PWM is started, so you need to wait even hundreds of ms, so you need to check the PWM state, e.g.
while( HAL_TIM_STATE_READY != HAL_TIM_PWM_GetState( &htim3))
{
HAL_Delay(100);
}
HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_1, _u16PWMTabServo[0], SERVO_POSITIONS);
while( HAL_TIM_STATE_READY != HAL_TIM_PWM_GetState( &htim3))
{
HAL_Delay(100);
}
HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_4, _u16PWMTabServo[1], SERVO_POSITIONS);