#include "TIM.h"
u8 ADC_Flag = 0;
void TIM2_Int_Init(u16 arr,u16 psc)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitTypeStruc;
NVIC_InitTypeDef NVIC_InitTypeStruc;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
TIM_TimeBaseInitTypeStruc.TIM_Period = arr;
TIM_TimeBaseInitTypeStruc.TIM_Prescaler = psc;
TIM_TimeBaseInitTypeStruc.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInitTypeStruc.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2,&TIM_TimeBaseInitTypeStruc);
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);//ÔêDí¸üDÂÖD¶Ï
NVIC_InitTypeStruc.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitTypeStruc.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitTypeStruc.NVIC_IRQChannelSubPriority = 1;
NVIC_InitTypeStruc.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitTypeStruc);
TIM_Cmd(TIM2,ENABLE);
}
void TIM2_IQRHandler(void)
{
if(TIM_GetITStatus(TIM2,TIM_IT_Update) == SET) //¼ì2éTIM2¸üDÂÖD¶Ï·¢éúóë·ñ
{
TIM_ClearITPendingBit(TIM2,TIM_IT_Update);//Çå3yTIM2¸üDÂÖD¶Ï±êÖ¾
ADC_Flag = 1;
}
}
不知道为什么就是进不去
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>