STM32F030C6 定时器16没有工作起来,求助各位,谢谢!配置如下:
void TIME16_Init()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* TIM16 clock enable */
RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM16, ENABLE);
TIM_DeInit(TIM16);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 1500;
TIM_TimeBaseStructure.TIM_Prescaler = 480-1; //48M/480=100000HZ
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM16, &TIM_TimeBaseStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM16_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ClearFlag(TIM16, TIM_IT_Update);
TIM_ITConfig(TIM16, TIM_IT_Update, ENABLE);
//TIM_ARRPreloadConfig(TIM16, ENABLE);
/* TIM16 enable counter */
TIM_Cmd(TIM16, ENABLE);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>