// 定时程序,等待时使用wfe,以节省功耗
static void TIM2_Delay_x500us(uint8_t count)
{
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
TIM2_TimeBaseInit(TIM2_Prescaler_16, TIM2_CounterMode_Up, 499 * count - 18);
TIM2_ClearFlag(TIM2_FLAG_Update);
TIM2_ClearITPendingBit(TIM2_IT_Update);
TIM2_ITConfig(TIM2_IT_Update, ENABLE);
TIM2_Cmd(ENABLE);
WFE_WakeUpSourceEventCmd(WFE_Source_TIM2_EV0, ENABLE);
wfe();
TIM2_Cmd(DISABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, DISABLE);
TIM2_ITConfig(TIM2_IT_Update, DISABLE);
}
以上我的程序,刚好也是 TIM2+wfe 请参考! |