AnsweredAssumed Answered

STM32L151UC: 'WFI' but interrupt never triggering

Question asked by Selportion on Jul 8, 2015
Latest reply on Jul 15, 2015 by Selportion

I am using an STM32L151 (Cortex-M3) and configuring an external interrupt on a gpio pin:

/* Enable clocks */ 
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE); 
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); 
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); 
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE); 
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM9, ENABLE); 
 
/* ExtInt Input */ 
GPIO_InitTypeDef GPIO_InitStr; 
GPIO_InitStr.GPIO_Speed = GPIO_Speed_40MHz; 
GPIO_InitStr.GPIO_Mode = GPIO_Mode_IN; 
GPIO_InitStr.GPIO_PuPd  = GPIO_PuPd_DOWN; 
GPIO_InitStr.GPIO_Pin = GPIO_Pin_13; 
GPIO_Init(GPIOC, &GPIO_InitStr); 
 
/* Interrupts on EXTINT */ 
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13); 
EXTI_InitTypeDef ExtiInitStr = {EXTI_Line13, EXTI_Mode_Interrupt, EXTI_Trigger_Rising, ENABLE}; 
EXTI_Init(&ExtiInitStr); 
NVIC_InitTypeDef NvicInitStr = {EXTI15_10_IRQn, 0, 0, ENABLE}; 
NVIC_Init(&NvicInitStr); 

My main.c eventually reaches a point where I have:

    __enable_irq(); 
//...program related code.. 
    __ASM volatile ("wfi"); 

At this point, the processor does NOT wake up from a the external pin going high. If I replace the WFI line instead with

while(1); 

the interrupt is triggered properly. I tried to follow examples but did not find something different. (I use ST-Link/V2 debugger,  GNU Tools for ARM Embedded Processors Toolchain & Eclipse plug-ins, with gdb and openOCD, if this matters)

Am I missing something very obvious?

Outcomes