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

Solution approach for handling GPIO interrupts. SDK 15.3 S132

Went through the pin_change_int example and of course it works fine.

Migrated that to custom board and it also worked fine with main loop.

So I then tried to use that as basis for real application that has to service an external interrupt.

In the main application, there are spi read and write functions.

When they are active and in a wait loop, the external interrupt is not triggered.

I am assuming that is because the priority level is the same and is therefore blocked.

I set the gpiote priority to 2 and still the interrupt is not triggered.

I am sure anyone reading sensors etc must deal with this type of problem everyday.

Right now the bluetooth stack and services are not being used and the interrupts still don't trigger.

The interrupt triggers once at startup but then never again.

In the pin_change_int example I did not see where the interrupt is cleared and enabled.

Is that what I am missing ? 

  • Looking at the code I don't see where the pin SENSE is actually enabled.

    20.1 Pin configuration
    Pins can be individually configured, through the SENSE field in the PIN_CNF[n] register, to detect either a high level or a low level on their input. When the correct level is detected on any such configured pin, the sense mechanism will set the DETECT signal high. Each pin has a separate DETECT signal

    C:\Projects\Nordic\nRF5_SDK_15.2.0\User\spi.h (1 hit)
    	Line 121: #define CC_IRQ_PIN								0
      C:\Projects\Nordic\nRF5_SDK_15.2.0\User\mainspi.c (6 hits)
    	Line 2: NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00000000;		// set as input with pullup
    	Line 813: NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00000000;		// set as input with pullup
    	Line 835:  //   NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00000000;			// set as input with pullup
    	Line 836: 	NRF_GPIOTE->CONFIG[0] = 0x00010001|((CC_IRQ_PIN)<<8);	// event mode, high to low transition
    	Line 1321:      err_code = nrf_drv_gpiote_in_init(CC_IRQ_PIN, &in_config, CC3100_IRQHandler);
    	Line 1331:     //    nrf_drv_gpiote_in_event_enable(CC_IRQ_PIN, true);
      C:\Projects\Nordic\nRF5_SDK_15.2.0\User\spi.c (4 hits)
    	Line 176:      nrf_drv_gpiote_in_event_enable(CC_IRQ_PIN, true);
    	Line 187:     nrf_drv_gpiote_in_event_disable(CC_IRQ_PIN);
    	Line 251: 	NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00000000;							// set as input with pullup
    	Line 252: 	//NRF_GPIOTE->CONFIG[1] = 0x00010001|((CC_IRQ_PIN)<<8);	// event mode, high to low transition

    E RW SENSE Pin sensing mechanism
    Disabled 0 Disabled, High 2 Sense for high level, Low 3 Sense for low level

    Line 2: NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00000000; // set as input with pullup

    I may be wrong, but I thought this command doesn't set the SENSE, which has to be set separately:

    	Line 836: 	NRF_GPIOTE->CONFIG[0] = 0x00010001|((CC_IRQ_PIN)<<8);	// event mode, high to low transition

    ie something like this:

    NRF_P0->PIN_CNF[CC_IRQ_PIN] = 0x00020000;		// set as input with pullup and Sense enabled

  • So I can use the SENSE even in high_accuracy mode and get an interrupt ? I will read more about that and thanks you for the suggestions. BTW - I took the initial advice and removed all the direct register settings and replaced with gpiote drv functions.  Still no luck getting the interrupt to trigger on pin 0 of the custom board while another on pin 27 that is activated by a button works fine. 

  • Oh and the obvious issue that might have crept in, though I imagine you tested for this:

        // 32kHz Osc pins can be used as GPIOs or 32kHz Oscillator, special case
        if ( (PinId == RCC_OSC_OUT_PIN) && (NRF_CLOCK->LFCLKSRC & 0x000001) ) return "RTC-OSC-OUT";

    ie, worth a check that pin P0.0 is still an i/o port ..

  • I will have to check on that. I saw it mentioned as a problem when using a certain DK.

    Sometimes obvious for one is not so much for the other, thanks. I will have to see how to check if this is the case.

  • Where is that code snippet from BTW? I don't find it in a search all files for my solution.

Related