在编写驱动数码管的程序,使用定时器6,发现没办法进入中断函数,求指教
时间:10-02
整理:3721RD
点击:
源程序如下:
void GPIO_TIM6_NL_Config(void) //配置定时器6,定时10ms
{
TIM_TimeBaseInitTypeDef TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
TimeBaseStructure.TIM_Period = 19;
TimeBaseStructure.TIM_Prescaler = 36000;
TimeBaseStructure.TIM_ClockDivision = TIM_CKD_div1;
TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6,&TimeBaseStructure);
TIM_ClearFlag(TIM6,TIM_FLAG_Update)
TIM_ITConfig(TIM6,TIM_IT_Update,ENABLE);?
TIM_Cmd(TIM6,ENABLE)
}
void NVIC_Config(void)//配置中断
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = TIM6_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIM6_IRQHandler(void)//中断服务函数
{
if(TIM_GetITStatus(TIM6,TIM_IT_Update) != RESET)
{
u8 i = 0;u8 j = 0;
TIM_ClearITPendingBit(TIM6,TIM_FLAG_Update);
NL_Scan();
i++;
if(i == 99)
{
i = 0;
TIME++;
if(j==0) {GPIO_SetBits(GPIOA,GPIO_Pin_5);j = 1;}
else {GPIO_ResetBits(GPIOA,GPIO_Pin_5);j = 0;}
if(TIME == 99) TIME = 0;
}
}
}
但中断服务函数没能执行,求大神指教
void GPIO_TIM6_NL_Config(void) //配置定时器6,定时10ms
{
TIM_TimeBaseInitTypeDef TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
TimeBaseStructure.TIM_Period = 19;
TimeBaseStructure.TIM_Prescaler = 36000;
TimeBaseStructure.TIM_ClockDivision = TIM_CKD_div1;
TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM6,&TimeBaseStructure);
TIM_ClearFlag(TIM6,TIM_FLAG_Update)
TIM_ITConfig(TIM6,TIM_IT_Update,ENABLE);?
TIM_Cmd(TIM6,ENABLE)
}
void NVIC_Config(void)//配置中断
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = TIM6_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIM6_IRQHandler(void)//中断服务函数
{
if(TIM_GetITStatus(TIM6,TIM_IT_Update) != RESET)
{
u8 i = 0;u8 j = 0;
TIM_ClearITPendingBit(TIM6,TIM_FLAG_Update);
NL_Scan();
i++;
if(i == 99)
{
i = 0;
TIME++;
if(j==0) {GPIO_SetBits(GPIOA,GPIO_Pin_5);j = 1;}
else {GPIO_ResetBits(GPIOA,GPIO_Pin_5);j = 0;}
if(TIME == 99) TIME = 0;
}
}
}
但中断服务函数没能执行,求大神指教