初级会员
- 积分
- 52
- 金钱
- 52
- 注册时间
- 2016-7-1
- 在线时间
- 6 小时
|
1金钱
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14,ENABLE);
TIM_TimeBaseInitStructure.TIM_Period = arr; //自动重装载值
TIM_TimeBaseInitStructure.TIM_Prescaler=psc; //定时器分频
TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //向上计数模式
TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM14,&TIM_TimeBaseInitStructure);
TIM_ITConfig(TIM14,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM14,ENABLE);
LCD_ShowString(30,210,200,16,16,"TIM_Cmd success");
NVIC_InitStructure.NVIC_IRQChannel=TIM8_TRG_COM_TIM14_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x03; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
LCD_ShowString(30,210,200,16,16,"TIM14_init success");
这里两个lcd函数是为了观察函数运行到哪里了,在lcd上只显示了TIM_Cmd successs,然后就死在那里了。
|
|