cancel
Showing results for 
Search instead for 
Did you mean: 

trying to understand EXTI example code

arro239
Senior
Posted on September 20, 2012 at 03:51

I have EXTI example running on my stm32f4 board but I am having trouble changing the PIN which causes the interrupt.

Here is the initialization method:

void EXTILine0_Config(void)

 

{

 

 

 

  GPIO_InitTypeDef   GPIO_InitStructure;

 

  NVIC_InitTypeDef   NVIC_InitStructure;

 

 

  /* Enable GPIOA clock */

 

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

 

  /* Enable SYSCFG clock */

 

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, 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);

 

 

  /* Connect EXTI Line0 to PA0 pin */

 

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);

 

 

  /* Configure EXTI Line0 */

 

  EXTI_InitStructure.EXTI_Line = EXTI_Line0;

 

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

 

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;  

 

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

 

  EXTI_Init(&EXTI_InitStructure);

 

 

  /* Enable and set EXTI Line0 Interrupt to the lowest priority */

 

  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;

 

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;

 

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;

 

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

 

  NVIC_Init(&NVIC_InitStructure);

 

}

I am trying to change the replace GPIO_Pin_0 in ''GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;'' but still - my led is controlled via the same user button, and via applying +3 to PA0, not any other PA pin. I have even tried changing EXTI_PinSource0 - same thing, only PA0 causes the interrupt. I have double checked that I am in fact rebuilding and reflashing a couple of times - I can easily change which LED I control with the EXTI, this confirm that I am in fact do execute the new binary.

What am I missing here?

#pa0 #falling-edge #interrupts
16 REPLIES 16
tranvanduy
Associate II
Posted on March 10, 2015 at 16:18

Thanks for your reply, it means i tested first time with PA0 OK, second time with PA1 OK, but the third time I only config PB1 as EXTI1 (not PA1 or both), but PB1 pin doesn't work, it works on PA1 pin instead.

Thanks you!

Posted on March 10, 2015 at 16:53

I have no insight into your board design, or code. You have posted to a >2 year old thread about a different chip.

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

Hihi, thank Mr Clive1 so much, I will check my problem again!

Have fun!

tranvanduy
Associate II
Posted on March 11, 2015 at 05:52

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6lJ&d=%2Fa%2F0X0000000buo%2FDCJBwL8Kl_0qGtAEMZ_jSXyRHTXV1EN7BIx3.pc4t1M&asPdf=false
Beck.Karl-Michael
Associate III
Posted on March 26, 2015 at 11:29

I'm currently also trying to setup a Interrupt by configuring the Registers of the cpu.

Inthe code above i see a function SYSCFG_EXTILineConfig. I just downloaded the latest board Support package (stm32cubef4 1.5.0.) and there is no such function. Where does this function come from? Also i'm missing the

NVIC_Init

function. I only have HAL_GPIO_Init and a bunch of registers. ^^
Posted on March 26, 2015 at 13:16

This thread is about using the

http://www.st.com/web/en/catalog/tools/PF257901

, not the HAL/Cube implementation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Beck.Karl-Michael
Associate III
Posted on March 26, 2015 at 16:10

Thanks for the help.