void Init_TIM2(void)
{
unsigned long num ;
if ( Voltage_X4K<2376)
{
num = 20000 ;
}
else if (Voltage_X4K<2376)
{
num = 2122;
}
else
{
num = 20000-8045*Voltage_X4K/8192;
}
TIM2_TimeBaseInit(TIM2_PRESCALER_2, num);//3770Hz
TIM2_OC1Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,0, TIM2_OCPOLARITY_HIGH);
TIM2_OC1PreloadConfig(ENABLE);
TIM2_Cmd(ENABLE);
哪位大侠帮我分析下怎么Voltage_X4K变化时 ,num这个变量不变化啊?
|