代码如下
#define LED3_PORT GPIOE
#define LED3_PIN GPIO_Pin_7
#define LED4_PORT GPIOC
#define LED4_PIN GPIO_Pin_7
#define WAKEUP_PORT GPIOE
#define WAKEUP_PIN GPIO_Pin_6
void main(void)
{
GPIO_Init(LED3_PORT,LED3_PIN,GPIO_Mode_Out_PP_High_Fast);//输出低电平-高速10M
GPIO_Init(LED4_PORT,LED4_PIN,GPIO_Mode_Out_PP_High_Fast); //输出低电平-高速10M
//GPIO_Init(CNT_EN_PORT,CNT_EN_PIN,GPIO_Mode_Out_PP_High_Fast);
GPIO_Init(WAKEUP_PORT,WAKEUP_PIN,GPIO_Mode_In_FL_IT);//PE6唤醒按键
//LCD_GLASS_Init();
//LCD_GLASS_DisplayString("M74HC");
/* Enable Rising edge port PE6 for wake up conter */
EXTI->CR2 = 0x10;
//上升沿或者下载沿都可以
EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Rising);
/* Enable Interrupts */
enableInterrupts();
while (1)
{
GPIO_ToggleBits(LED3_PORT,LED3_PIN);
halt();//进入HALT模式,外部中断能够唤醒
}
}
目的应该是,LED3闪然后进入停机,等我按键以后LED4闪然后从停机中唤醒出来。为何进入不了停机呢?我没有按键就只有两个LED灯轮流闪,有大侠帮我吗???
以下是stm8l15x_it.c中的代码
INTERRUPT_HANDLER(EXTI6_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
asm("sim");
GPIO_ToggleBits(GPIOC,GPIO_Pin_7);
/* Clear Interrupt pending bit */
EXTI_ClearITPendingBit(EXTI_IT_Pin6);
asm("rim");
} |