本帖最后由 serac 于 2010-1-7 15:07 编辑
定时器2配置
void TIM2_Configuration(void)
{
TIM_TimeBaseInitTypeDef TIM_BaseInitStructure;
TIM_BaseInitStructure.TIM_Period = 0XFFFF; //自动重装载的值
TIM_BaseInitStructure.TIM_Prescaler = 0; //计数器的时钟频率(CK_CNT)等于fCK_PSC/( PSC[15:0]+1)
TIM_BaseInitStructure.TIM_ClockDivision = 0;//时钟分频因子 288MHZ
TIM_BaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_BaseInitStructure); // Time base configuration
TIM_ETRClockMode2Config(TIM2, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_Inverted, 0);
TIM_SetCounter(TIM2, 0);
TIM_Cmd(TIM2, ENABLE);
i
} |