新手上路
积分 23
金钱 23
注册时间 2018-3-8
在线时间 4 小时
1 金钱
按键双击程序
在第一个按键中断函数中打开定时器,程序会有40%的概率会立即进入第二个定时器中断函数。不是在设定的时间之后进入定时器中断。
INTERRUPT_HANDLER(EXTI3_IRQHandler,11)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
halWait(2500);//延时10ms
if(((GPIOB->IDR & (uint8_t)GPIO_Pin_3)==0x08)&((RF_TS_FLAG & BUS_FLAG_TEST)==0))
{ //&((RF_TS_FLAG & BUS_FLAG_TEST)==0)
if(PressButton ==0)
{
PressButton = 1;
LED1ON;
//CLK->PCKENR1 |= (uint8_t)((uint8_t)1 << ((uint8_t)CLK_Peripheral_TIM2 & (uint8_t)0x0F));
//CLK->PCKENR1 |= CLK_PCKENR1_TIM4;
TIM4->IER &= ~ TIM4_IER_UIE;
TIM4->SR1 = 0;
TIM4->PSCR = 0x07;
TIM4->CNTR = 0x00;
TIM4->EGR=0x01;
TIM4->ARR = 0xFF;
TIM4->CR1 |= TIM4_CR1_CEN;
TIM4->EGR=0x01;
while((TIM4->SR1&0x01)==0);
TIM4->SR1 = 0;
TIM4->IER |= TIM4_IER_UIE;
}
else
{
TIM4->IER &= ~ TIM4_IER_UIE;
TIM4->EGR=0x00;
TIM4->CR1 = 0;
TIM4->SR1 = 0;
TIM4->ARR = 0;
TIM4->CNTR = 0;
PressButton = 0;
RF_TS_FLAG |= BUS_FLAG_TEST;
FlagReg &=~ bFireBuzzFlag;
Radio_ChannelNumberBuf = 0;
LED1OFF;
}
}
/*Cleat Interrupt pending bit*/
//EXTI_ClearITPendingBit(EXTI_IT_Pin4);
EXTI->SR1 = (uint8_t) (EXTI_IT_Pin3);
}
INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler,25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
PressButton = 0;
LED1OFF;
TIM4->EGR=0x00;
TIM4->CR1 = 0;
TIM4->IER &= ~ TIM4_IER_UIE;
TIM4->SR1 = 0;
TIM4->CNTR = 0;
RTC_ClearITPendingBit(RTC_IT_WUT);
}
我来回答