I need to enable a general timer interrupt after generating each pulse in PWM mode. I wrote this program. I will be grateful if you kindly let me know how to enable timer interrupt. This my SPL schematic code:
void PWMControl(unsigned int Freq){
TIM_TimeBaseInitTypeDef TimeStructureure;
TIM_OCInitTypeDef TIMOCStructureure;
TimeStructure.TIM_Prescaler=Prescale;
TimeStructure.TIM_CounterMode=TIM_CounterMode_Up;
TimeStructure.TIM_Period=Period;
TimeStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TimeStructure.TIM_RepetitionCounter=0;
TIM_TimeBaseInit(TIM4, &TimeStructure);
TIM_Cmd(TIM4, ENABLE);
TIMOCStructure.TIM_OCMode=TIM_OCMode_PWM2;
TIMOCStructure.TIM_OutputState=TIM_OutputState_Enable;
TIMOCStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIMOCStructure.TIM_Pulse=Pulse;
TIM_OC1Init(TIM4, &TIMOCStructure);
//TIM_OC1PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_ITConfig(TIM4,TIM_IT_Update,ENABLE);
}
According to this post I need to generate N pulse without/ the least CPU workload. (Max Frequency=1MHz)