cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 exti always pending

danashevskiy
Associate II
Posted on September 30, 2015 at 14:34

In my project based on stm32F107 i use four pins (PINE 12-15) to catch rising level on them.

My problem: two pins always produce external interrupts but there are no rising level on them and other two pins never respond to rising level.

My question: i'm looking for some debug ways and may be advices. May be reading some registers in the interrupt routine will help to solve my problem

Here is my code:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;

GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13;

GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_14;

GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;

GPIO_Init(GPIOE, &GPIO_InitStruct);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

// KeyI_0

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_12);

EXTI_InitStructure.EXTI_Line = EXTI_Line12;

EXTI_Init(&EXTI_InitStructure);

// KeyI_1

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_13);

EXTI_InitStructure.EXTI_Line = EXTI_Line13;

EXTI_Init(&EXTI_InitStructure);

// KeyI_2

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_14);

EXTI_InitStructure.EXTI_Line = EXTI_Line14;

EXTI_Init(&EXTI_InitStructure);

// KeyI_3

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_15);

EXTI_InitStructure.EXTI_Line = EXTI_Line15;

EXTI_Init(&EXTI_InitStructure);

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;

NVIC_Init(&NVIC_InitStructure);

void

EXTI15_10_IRQHandler(

void

)

{

printf(

''exti\n''

);

if

(EXTI_GetFlagStatus(EXTI_Line12) != RESET) {

EXTI_ClearITPendingBit(EXTI_Line12);

printf(

''key1\n''

);

//keyboard_StringStart(0);

}

else

if

(EXTI_GetFlagStatus(EXTI_Line13) != RESET) {

EXTI_ClearITPendingBit(EXTI_Line13);

printf(

''key2\n''

);

//keyboard_StringStart(2);

}

else

if

(EXTI_GetFlagStatus(EXTI_Line14) != RESET) {

EXTI_ClearITPendingBit(EXTI_Line14);

printf(

''key3\n''

);

//keyboard_StringStart(3);

}

else

if

(EXTI_GetFlagStatus(EXTI_Line15) != RESET) {

EXTI_ClearITPendingBit(EXTI_Line15);

printf(

''key4\n''

);

//keyboard_StringStart(1);

}

}

#exti #stm32f107

2 REPLIES 2
qwer.asdf
Senior
Posted on September 30, 2015 at 14:55

Are you sure you must configure the inputs as floating? Maybe you must pull them down or something?

danashevskiy
Associate II
Posted on October 01, 2015 at 09:16

So it was mistake in code syntax.

That is wrong:

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_12);

That is correct:

GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource12);

Sorry for wasting your time.