AnsweredAssumed Answered

STM32L Interrupt not firing. SOS!!

Question asked by Bharath Kumar on Apr 20, 2017
Latest reply on Apr 20, 2017 by Alex R

I'm new to STM32 line of Microcontrollers, However I have worked extensively on TI MSP430 line.

I recently bought STM32L-DISCOVERY with STM32L152RCT6 controller onboard.

I got the en.stsw-stm32077 standard peripherals and CSIR from STM website.

 

I'm using IAR-EWARM Toolchain with a linker supplied from STM32 Website. 

My problems with the following code are as follows.

 

  1. Unable to set breakpoints inside the void EXTI0_IRQHandler(void) routine. IAR does not accept.
  2. The code when put in run mode should actually toggle the LED when interrupted by a falling edge on PA0 which it doesn't. Is there something wrong with the below code.The LED works when put in while mode, so its mostly related to the Interrupt not firing.

 

Could some one identify the problem?

 

#include "stm32l1xx.h"

#include "Pinouts.h"
#include "Settings.h"
#include "functions.h"

#include "LIB_WSN.h"
#include "LIB_CC1101.h"

#include "Variables.h"

char buffer, addr;

EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

void EXTI0_Config(void);

 

int main()
{
//WiNode.Init();

//WiNode.Init_CLK();

WiNode.Init_LED();

/* Configure PA0 in interrupt mode */
EXTI0_Config();

/* Generate software interrupt: simulate a falling edge applied on EXTI0 line */
//EXTI_GenerateSWInterrupt(EXTI_Line0);

while(1)
{

}
}
void EXTI0_Config(void)
{
/* Enable GPIOA clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

/* Configure PA0 pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOA, &GPIO_InitStructure);

 

/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

 

/* Connect EXTI0 Line to PA0 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);

 

/* Configure EXTI0 line */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

/* Enable and set EXTI0 Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}


/* Set interrupt handlers */
/* Handle PA0 interrupt */
void EXTI0_IRQHandler(void) {

if (EXTI_GetITStatus(EXTI_Line0) != RESET) {
GPIO_SetBits(LED_GPIO, LEDON_PIN);
delay_ms(1000);
GPIO_ResetBits(LED_GPIO, LEDON_PIN);
EXTI_ClearITPendingBit(EXTI_Line0);
}

EXTI_ClearFlag(EXTI_Line0) ;
EXTI_ClearITPendingBit(EXTI_Line0);

}

 

Outcomes