下面这段代码中断标志位没有清楚,为什么还会无限进入中断
#include "INTER.h"
#include "led.h"
#include "delay.h"
TIM_ICInitTypeDef ICstructure;
u16 VAL,STA;
void ccap_init(u16 prer,u16 rlr)
{
TIM_TimeBaseInitTypeDef TIM2structure;
NVIC_InitTypeDef NVICstructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE) ;
TIM2structure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM2structure.TIM_CounterMode=TIM_CounterMode_Up;
TIM2structure.TIM_Period=rlr;
TIM2structure.TIM_Prescaler=prer;
TIM_TimeBaseInit(TIM2,&TIM2structure);
NVICstructure.NVIC_IRQChannel=TIM2_IRQn;
NVICstructure.NVIC_IRQChannelCmd=ENABLE;
NVICstructure.NVIC_IRQChannelPreemptionPriority=2;
NVICstructure.NVIC_IRQChannelSubPriority=2;
NVIC_Init(&NVICstructure);
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM2,ENABLE);
}
void TIM2_IRQHandler()
{
led1=!led1;
delay_ms(1000);
}
#include "stm32f10x.h"
#include "INTER.h"
#include "led.h"
#include "delay.h"
#include "usart.h"
int main()
{
delay_init();
led_init();
ccap_init(0,899);
while(1);
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>