cancel
Showing results for 
Search instead for 
Did you mean: 

long press problem

David.Cheng
Associate II
void main(void)
{
  /* Infinite loop */
  
    CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_8);
  
    GPIO_Init(GPIOE, GPIO_Pin_7, GPIO_Mode_In_PU_IT);
    EXTI_setup();
 
    halt(); // first active
    
    
    #if 0
    while(1)
    {
        halt();
        delay_ms(1000);
        
        if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_7) == 0)
        {
            //i++;
            //if(i == 25)
            break;
        }
        
        
    }
    #endif
    usart_setup();
    USART_SendData8(USART1, 'a');
    USART_SendData8(USART1, 'b');
  
  while (1)
  {
  }
}
void EXTI_setup(void)
{
 
    ITC_DeInit();
    ITC_SetSoftwarePriority(EXTI7_IRQn, ITC_PriorityLevel_1);
 
    
    EXTI_DeInit();
 
    EXTI_SetPinSensitivity(GPIO_Pin_7, EXTI_Trigger_Falling);
    //EXTI_SetPinSensitivity(GPIO_Pin_7, EXTI_Trigger_Rising);
    //EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_FALL_ONLY);
    enableInterrupts();
 
}

when in long press, it does not wakeup.

until release , then wakeup

4 REPLIES 4
JoniS
Senior

EXTI_SetPinSensitivity(GPIO_Pin_7, EXTI_Trigger_Rising);

Change the trigger for that interrupt to rising edge instead of falling edge, then it should wake up instantly.​

debug long time, falling edge can not

when change to rising edge , configure pe7 to floating input with it , and gpio connect to gnd directly?

JoniS
Senior

Can you post the schematic how the button is connected?

For rising edge to work, the io should be pulled down, and button then connects it to VCC.

For falling edge to work, IO should be pulled to VCC, button then grounds it.

Based on your initial proplem description i assume the IO is pulled low(gnd) and the button connects to vcc, which would result to behaviour you observe, which is that mcu wakeups when the button is released.​

David.Cheng
Associate II

0690X00000AqTr8QAF.png

the falling edge one