This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Missing Interrupts on GPIOE PORT events

we're using Mbed for NRF51822. our board using 2 GPIOs interrupt.image description

problem: the Rise edge did not generate the Interrupt event: set EVENTS_PORT. I try uisng while, but it did not working: volatile uint32_t newVal = NRF_GPIO->IN;

    while ( (NRF_GPIOTE->EVENTS_PORT != 0) && ( (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_PORT_Msk) != 0) ){
        newVal = NRF_GPIO->IN;
//    if ( (NRF_GPIOTE->EVENTS_PORT != 0) && ( (NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_PORT_Msk) != 0) ){
        NRF_GPIOTE->EVENTS_PORT = 0;
        setisrcheck001(1);
        for(uint8_t i=0;i<31;i++){
            if(channel_ids[i]>0){
                if(channel_enabled[i]){
                    if( ((newVal>>i)&1)  && ( ( (NRF_GPIO->PIN_CNF[i] >>GPIO_PIN_CNF_SENSE_Pos) & GPIO_PIN_CNF_SENSE_Low) != GPIO_PIN_CNF_SENSE_Low) && ( (portRISE>>i)&1) ){
                            irq_handler(channel_ids[i], IRQ_RISE);            
                    }                    
                    else if( ( ((newVal>>i)&1) == 0) && ( ( (NRF_GPIO->PIN_CNF[i] >>GPIO_PIN_CNF_SENSE_Pos)&GPIO_PIN_CNF_SENSE_Low) == GPIO_PIN_CNF_SENSE_Low) && ( (portFALL>>i)&1) ){
                            irq_handler(channel_ids[i], IRQ_FALL);
                    }                    
                }

                if(NRF_GPIO->PIN_CNF[i] &GPIO_PIN_CNF_SENSE_Msk){
                    NRF_GPIO->PIN_CNF[i] &= ~(GPIO_PIN_CNF_SENSE_Msk);
                                         
                    if(newVal>>i &1){
                         NRF_GPIO->PIN_CNF[i] |= (GPIO_PIN_CNF_SENSE_Low     << GPIO_PIN_CNF_SENSE_Pos) ;
                    }
                    else{
                         NRF_GPIO->PIN_CNF[i] |= (GPIO_PIN_CNF_SENSE_High     << GPIO_PIN_CNF_SENSE_Pos) ;
                    }
                }
            }
        }
        setisrcheck001(0);
    }

the Rise edge of RED signal should generate another interrupt. but seem failed.

Question:

  1. what's condition to generate EVENTS_PORT in GPIOTE_IRQHandler() process? it' seem just clear EVENTS_PORT not enough.
  2. how the GPIOE EVENTS_PORT generate when multi-GPIOs rise and fall ?
  • @wen jin zhang :

    1. GPIOTE PORT event generated on the rising edge of DETECT signal. Please have a look at section 15.1.2

    2)DETECT signal is common signal when multiple pins are configured with SENSE mechanism. The DETECT signal is only cleared when all of the pin with SENSE mechanism is inactive. So if there still one pin is active, you won't be able to receive another interrupt on GPIOTE PORT event.

    It's hard for me to understand the red signal. Could you capture another trace which may show the issue more clearly ?

  • Thanks for help! my case look like these:

    1. 2 GPIOs interrupt happened.
    2. GPIOTE_IRQHandler clear PORT EVENT.
    3. first ISR execute, the first GPIO level to change HIGH.
    4. set first GPIO SENSE mechanism to HIGH. it'll active. but NO PORT EVENT/Interrupt because still has other pin active.
    5. second ISR execute, and it change GPIO SENSE mechanism level. it deactived. but DETECT signal did not clear.
    6. GPIOTE_IRQHandler() finished. exit interrupt.
    7. No PORT EVENT/interrupt generate for first GPIO interrupt.

    question:

    1. is there any solution for these case?
    2. is DETECT signal for each GPIO pin and there has another DETECT signal for all? section 14 figure 15.
  • @Wen: When 2 GPIOs with SENSE mechanism is active at the same time. You only have one interrupt for both of them because DETECT signals of each GPIO pins are connected together. There is only one DETECT signal for all pins. So as long as there is one GPIO pin is active, other GPIO pin won't be able to trigger another GPIOTE PORT event, even if you clear PORT even.

    What you can do is to switch off all other GPIOTE pins sense mechanism when you are in GPIOTE IRQ Handler. Then you flip the sense level of the pin that cause the DETECH signal to high. At this point the DETECT level should be low, and ready for another interrupt if there is.

    After that you can turn the SENSE mechanism back on other pins.

    This way you can make sure other change on other pins can trigger another GPIOTE PORT event.

  • but if we must detect the high level, that way of resolution can work fine?

  • @James: I don't fully understand what you asked. Please create a new question with more detail.

Related