AnsweredAssumed Answered

stm32 exti always pending

Question asked by r_spb on Sep 30, 2015
Latest reply on Oct 1, 2015 by r_spb
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:

01.RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
02. 
03.      GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
04.      GPIO_InitStruct.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
05. 
06.      GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;
07.      GPIO_Init(GPIOE, &GPIO_InitStruct);
08. 
09.      GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13;
10.      GPIO_Init(GPIOE, &GPIO_InitStruct);
11. 
12.      GPIO_InitStruct.GPIO_Pin = GPIO_Pin_14;
13.      GPIO_Init(GPIOE, &GPIO_InitStruct);
14. 
15.      GPIO_InitStruct.GPIO_Pin = GPIO_Pin_15;
16.      GPIO_Init(GPIOE, &GPIO_InitStruct);
17. 
18.    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
19. 
20.      EXTI_InitStructure.EXTI_Mode    = EXTI_Mode_Interrupt;
21.      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
22.      EXTI_InitStructure.EXTI_LineCmd = ENABLE;
23. 
24.    // KeyI_0
25.        GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_12);
26.        EXTI_InitStructure.EXTI_Line    = EXTI_Line12;
27.        EXTI_Init(&EXTI_InitStructure);
28. 
29.    // KeyI_1
30.        GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_13);
31.        EXTI_InitStructure.EXTI_Line    = EXTI_Line13;
32.        EXTI_Init(&EXTI_InitStructure);
33. 
34.    // KeyI_2
35.        GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_14);
36.        EXTI_InitStructure.EXTI_Line    = EXTI_Line14;
37.        EXTI_Init(&EXTI_InitStructure);
38. 
39.    // KeyI_3
40.        GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_Pin_15);
41.        EXTI_InitStructure.EXTI_Line    = EXTI_Line15;
42.        EXTI_Init(&EXTI_InitStructure); 
43. 
44.    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
45.      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
46.      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;          
47.      NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
48.      NVIC_Init(&NVIC_InitStructure);
49. 
50. void EXTI15_10_IRQHandler(void)
51.{
52.  printf("exti\n");
53.  if (EXTI_GetFlagStatus(EXTI_Line12) != RESET) {
54.    EXTI_ClearITPendingBit(EXTI_Line12);
55.    printf("key1\n");
56.    //keyboard_StringStart(0);
57.  } else if (EXTI_GetFlagStatus(EXTI_Line13) != RESET) {
58.      EXTI_ClearITPendingBit(EXTI_Line13);
59.      printf("key2\n");
60.      //keyboard_StringStart(2);
61.  } else if (EXTI_GetFlagStatus(EXTI_Line14) != RESET) {
62.      EXTI_ClearITPendingBit(EXTI_Line14);
63.      printf("key3\n");
64.      //keyboard_StringStart(3);
65.  } else if (EXTI_GetFlagStatus(EXTI_Line15) != RESET) {
66.      EXTI_ClearITPendingBit(EXTI_Line15);
67.      printf("key4\n");
68.      //keyboard_StringStart(1);
69.  }
70.}

Outcomes