2024-11-17 12:52 PM
Chip: STM32H747
I have setup a master timer.
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_ENABLE;
And two slave timers each with
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_COMBINED_RESETTRIGGER;
sConfigOC.OCMode = TIM_OCMODE_TOGGLE;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
The slave timers correctly start when the master timer starts
I first start the slave timer
HAL_TIM_Base_Start(&htim_adc);
HAL_TIM_OC_Start(&htim_adc, ADC_SAMPLING_TIMER_CHANNEL);
..as expected no timer output until I start the master timer
At a certain moment I stop the master and slave timers
HAL_TIM_OC_Stop(&master, ...);
HAL_TIM_Base_Stop(&master);
// reset
HAL_TIM_GenerateEvent(&master, ...);
__HAL_TIM_SET_COUNTER(&master, 0);
// also stop/reset the slave timer
HAL_TIM_OC_Stop(&htim_adc, ADC_SAMPLING_TIMER_CHANNEL);
HAL_TIM_Base_Stop(&htim_adc);
HAL_TIM_GenerateEvent(&htim_adc, TIM_EVENTSOURCE_UPDATE);
__HAL_TIM_SET_COUNTER(&htim_adc, 0);
Then I restart the timer, it won't be enabled until master actually starts:
HAL_TIM_Base_Start(&htim_adc);
HAL_TIM_OC_Start(&htim_adc, ADC_SAMPLING_TIMER_CHANNEL);
But, now, even though the master time is not started, sometimes the channel output changes once. It seems that the previous timer counter value vs. compare state plays a role in this. How do I also reset the timer output?
I have checked the register values in the htim_adc.Instance struct. There was no difference, in the 2 situations.
2024-11-17 10:02 PM
I also tried setting the pulse value to period-1, so that setting the counter to zero should not cause a compare. But alas, no effect.