我用TIME2通道一 捕获一方波信号,通道二,三,四进行比较中断.
初始化程序如下: 计数器顶点11000,比较器2先为30000,目的是不想进入比较2中断,
但我一启动计数器,这几个中断好像就同时产生了.都进入了中断.以后就正常了.不会产生
二号比较中断了.想问问大家这是怎么回事.
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 11000;
TIM_TimeBaseStructure.TIM_Prescaler = 71;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* TIM2 PWM2 Mode configuration: Channel1
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_Channel = TIM_Channel_2;
TIM_OCInitStructure.TIM_Pulse = 6383;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInit(TIM2, &TIM_OCInitStructure); */
/* TIM2 configuration in Input Capture Mode */
/*
TIM2->CCR1=10000;
TIM2->CCR2=0;
TIM2->CCR3=9500;
TIM2->CCMR1=0x1010;
TIM2->CCMR2=0x0010;
TIM2->CCER=0x0001;
TIM2->DIER=0x000E;
//TIM2->CR1=0x0001 ; */
//* 临时改
TIM2->CCR1=10000;
TIM2->CCR2=30000;
TIM2->CCR3=9500;
TIM2->CCR4=10900;
//TIM2->CCR4=11000;
TIM2->CCMR1=0x1081;
TIM2->CCMR2=0x0010;
TIM2->CCER=0x0001;
TIM2->DIER=0x001E;
TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_ICAP;
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter =8;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
/* One Pulse Mode selection */
// TIM_SelectOnePulseMode(TIM2, TIM_OPMode_Single);
/* Input Trigger selection */
//TIM_SelectInputTrigger(TIM2, TIM_TS_TI1FP1);
/* Slave Mode selection: Trigger Mode */
// TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Trigger);
TIM2->CR1|=0x0001;//start TIM2 |