Question
Doubts in generating fixed number of PWM Waves
I am trying to generate a fixed number of PWM Waves using stm32f407. I called both functions
HAL_TIM_Base_Start_IT(&htim2);
HAL_TIM_PWM_Start_IT(&htim2,TIM_CHANNEL_1);and in the ISR
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
pwmCount ++;
if (pwmCount == 1001){
HAL_TIM_Base_Stop_IT(&htim2);
HAL_TIM_PWM_Stop_IT(&htim2,TIM_CHANNEL_1);
}
}The problem is if we have to generate n number of pulses we have to give n+1 in the condition(eg: if I want to generate 1000 pulses I have to give 1001) what will be the reason?
And also if check pwmCount ==1 (for generating a single pulse) it continuously gives the pulses.
Anyone please clarify these two doubts