初级会员
- 积分
- 134
- 金钱
- 134
- 注册时间
- 2018-3-26
- 在线时间
- 286 小时
|
请教一下大家,我把标准定时器历程里的TIM3改成TIM5,但是不进中断,这是为什么?
- int main(void)
- {
- delay_init(); //Ñóê±oˉêy3õê¼»ˉ
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// éèÖÃÖD¶ÏóÅÏ輶·Ö×é2
- LED_Init(); //3õê¼»ˉóëLEDᬽóμÄó2¼t½ó¿ú
- uart_init3(9600);
- TIM5_Int_Init(4999,7199);
复制代码- void TIM5_Int_Init(u16 arr,u16 psc)
- {
- TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
- NVIC_InitTypeDef NVIC_InitStructure;
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE); //????
- TIM_TimeBaseStructure.TIM_Period = arr; //??????????????????????????? ???5000?500ms
- TIM_TimeBaseStructure.TIM_Prescaler =psc; //??????TIMx??????????? 10Khz?????
- TIM_TimeBaseStructure.TIM_ClockDivision = 0; //??????:TDTS = Tck_tim
- TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM??????
- TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure); //??TIM_TimeBaseInitStruct?????????TIMx???????
- TIM_ITConfig(TIM5,TIM_IT_Update,ENABLE ); //?????TIM3??,??????
- NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn; //TIM3??
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //?????0?
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //????3?
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?????
- NVIC_Init(&NVIC_InitStructure); //??NVIC_InitStruct???????????NVIC???
- TIM_Cmd(TIM5, ENABLE); //??TIMx??
- }
- void TIM5_IRQHandler(void) //TIM3??
- {
- if (TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET) //?????TIM??????:TIM ???
- {
- TIM_ClearITPendingBit(TIM5, TIM_IT_Update ); //??TIMx???????:TIM ???
- BEEP=!BEEP;
- }
- }
复制代码
|
|