wfi和wfe
1. WFI與WFE的區(qū)別為,WFI等待的是中斷,而WFE等待是事件,所以WFE不能進入中斷服務函數(shù),而WFI可以。
2. 實驗現(xiàn)象和WFE一樣。
? ? CLK_Config();//切換LSI為主時鐘
? ??
? ? //不使用的IO全部設置為輸出低電平
? ? GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);
? ? GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);
? ? GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);
? ? GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);
??
? ? GPIO_Init(LED_GPIO_PORT, LED_GPIO_PINS, GPIO_Mode_Out_PP_Low_Slow);//GPIO初始化
? ? GPIO_Init(KEY_GPIO_PORT, KEY_GPIO_PINS, GPIO_Mode_In_PU_IT);//初始化按鍵,GPB6上拉輸入
? ? EXTI_SetPinSensitivity (EXTI_Pin_6,EXTI_Trigger_Falling);//外部中斷1,下降沿觸發(fā)
? ? enableInterrupts();//使能中斷
? ??
? ? while(1)
? ? {
? ? ? ? GPIO_ToggleBits(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS);//翻轉LED端口電平
? ? ? ? Delay(0x00FF);
? ? ? ??
? ? ? ? wfi();
? ? ? ??
? ? ? ? GPIO_ToggleBits(LED_GPIO_PORT, (GPIO_Pin_TypeDef)LED_GPIO_PINS);//翻轉LED端口電平
? ? ? ? Delay(0x00FF);
? ? ? ??
? ? }
INTERRUPT_HANDLER(EXTI6_IRQHandler,14)
{
? ? /* In order to detect unexpected events during development,
? ? ? ?it is recommended to set a breakpoint on the following instruction.
? ? */
?EXTI_ClearITPendingBit (EXTI_IT_Pin6);//清除中斷標志 WFE模式下 該句放在while循環(huán)里面
}
總結
- 上一篇: win10 安装xilinx 14.7
- 下一篇: stm32 gpio口的工作模式