cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 EXTI not firing?

danielblesener9
Associate II
Posted on April 20, 2015 at 15:50

Written this code many times. No clue why it is not working. See any obvious errors?

//CODE FOR INIT. Note that APB2 clocks are initialized for ports

  GPIO_InitTypeDef GPIO_EXTI0;

 

  GPIO_EXTI0.GPIO_Pin = GPIO_Pin_7;

  GPIO_EXTI0.GPIO_Mode = GPIO_Mode_IN_FLOATING;

  GPIO_Init(GPIOA, &GPIO_EXTI0);

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

  GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource7);

  EXTI_InitTypeDef   EXTI_InitStructure;

  EXTI_InitStructure.EXTI_Line = EXTI_Line7;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  NVIC_InitTypeDef NVIC_InitStructure;

 

  NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

 

  GPIO_InitTypeDef GPIO_InitStructure4;

  GPIO_InitStructure4.GPIO_Pin = GPIO_Pin_4;

  GPIO_InitStructure4.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure4.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_Init(GPIOC, &GPIO_InitStructure4);

  GPIO_ResetBits(GPIOC, GPIO_Pin_4);                            //All LED control is made with 3.3V-->220R-->MCU, so pull down to turn on.

//CODE FOR INTERUPT 

void EXTI9_5_IRQHandler(void)

{

  if(EXTI_GetITStatus(EXTI_Line7) != RESET)

  {

    /* Clear the  EXTI line 0 pending bit */

    EXTI_ClearITPendingBit(EXTI_Line7);

        if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_7))

            {

            lsb = GPIO_ReadInputData(GPIOG);

            msb = GPIO_ReadInputData(GPIOF) & 0b0000000001111111;

            msb = msb<<16;

            final_val = lsb | msb;

            clear_shift_reg();

           

            }

  }

 

}Thanks!
3 REPLIES 3
Posted on April 20, 2015 at 18:21

GPIO Clocks enabled?

C++ Name Mangling?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
danielblesener9
Associate II
Posted on April 20, 2015 at 22:50

Ports are enabled. What do you mean by c++ name mangling?

Posted on April 20, 2015 at 23:01

C++ changes function names based on parameters passed and returned.

EXTI9_5_IRQHandler might be something else from the linker's perspective, and not bind to the vector table in the manner you had hoped.

http://en.wikipedia.org/wiki/Name_mangling

extern ''C'' void EXTI9_5_IRQHandler(void)

{

}

Not much of a C++ guy myself, but you use declarations mid function.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..