我就想用STM32F定时器最简单的定时溢出功能,我应该配置哪几个的寄存器? 我执行了如下初始化程序,TIM2_CNT竟然不走 void TIM2_config(void) { /* Time base configuration[初始化时间基单元] */ TIM_TimeBaseStructure.TIM_Period = 0x1000;//周期值 TIM_TimeBaseStructure.TIM_Prescaler = 0;//时钟的预分频数=0x0000 TIM_TimeBaseStructure.TIM_ClockDivision = 0;//TIM_ClockDivision 配置时钟分割 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//向上计数 TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* Prescaler configuration [配置TIM的预分频数]*/ TIM_PrescalerConfig(TIM2,3600, TIM_PSCReloadMode_Immediate);//TIM2,1分频,预分频数立即载入
TIM_UpdateDisableConfig(TIM2,ENABLE); /* TIM IT enable [使能TIM2比较中断]*/ TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); /* TIM2 enable counter */ TIM_Cmd(TIM2, ENABLE); }
|