有没有大神帮忙看一下,什么问题,代码如下:
void TIM6_Init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE); //tim6时钟使能,APB时钟48M
TIM_TimeBaseInitStructure.TIM_Period = 500;
TIM_TimeBaseInitStructure.TIM_Prescaler = 48000-1; //定时500ms
TIM_TimeBaseInitStructure.TIM_ClockDivision = 0 ; //TIM_CKD_DIV1 分频系数为1
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseInitStructure);
NVIC_InitStructure.NVIC_IRQChannel = 17;//TIM6_DAC_IRQn //定时器6中断
NVIC_InitStructure.NVIC_IRQChannelPriority = 1; //优先级0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
// TIM_ClearITPendingBit(TIM6,TIM_IT_Update);
TIM_ITConfig(TIM6,TIM_IT_Update,ENABLE); //允许定时器6更新中断
TIM_Cmd(TIM6,ENABLE); //使能定时器6
}
void TIM6_DAC_IRQHandler(void)
{
if(TIM_GetITStatus(TIM6,TIM_IT_Update) != RESET) //溢出中断
{
LED_TURN;
}
TIM_ClearITPendingBit(TIM6,TIM_IT_Update); //清除中断标志位
// TIM6->SR &= ~(1<<0);
// LED_TURN;
}
//== |