|
朋友的疑问:
请教这样一段程序
void TIM2_IRQHandler(void)
{
/* TIM2_CH1 toggling with frequency = 183.1 Hz */
if (TIM_GetITStatus(TIM2, TIM_IT_CC1) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_CC1 );
capture1 = TIM_GetCapture1(TIM2);
TIM_SetCompare1(TIM2, capture1 + CCR1_Val );
}
/* TIM2_CH2 toggling with frequency = 366.2 Hz */
if (TIM_GetITStatus(TIM2, TIM_IT_CC2) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
capture2 = TIM_GetCapture2(TIM2);
TIM_SetCompare2(TIM2, capture2 + CCR2_Val);
}
/* TIM2_CH3 toggling with frequency = 732.4 Hz */
if (TIM_GetITStatus(TIM2, TIM_IT_CC3) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_CC3);
capture3 = TIM_GetCapture3(TIM2);
TIM_SetCompare3(TIM2, capture3 + CCR3_Val);
}
/* TIM2_CH4 toggling with frequency = 1464.8 Hz */
if (TIM_GetITStatus(TIM2, TIM_IT_CC4) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_CC4);
capture4 = TIM_GetCapture4(TIM2);
TIM_SetCompare4(TIM2, capture4 + CCR4_Val);
}
}
其中 capture4 = TIM_GetCapture4(TIM2);
TIM_SetCompare4(TIM2, capture4 + CCR4_Val)
这两个语句是用来获得捕获比较寄存器的数值,并且再叠加上CCRX_Val变量的数值重新赋值给不活比较寄存器。
那么我有一个疑问,如果这个中断不断执行,是不是captureX里面的述职会不断增加知道溢出?也就是这样比产生的方波频率是始终变化的?
|
|