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 ? 

Parents
  • 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. 

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

  • Check the LF Clock setting:

    // <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
    
    // <0=> RC
    // <1=> XTAL
    // <2=> Synth
    
    #ifndef CLOCK_CONFIG_LF_SRC
    #define CLOCK_CONFIG_LF_SRC 1
    #endif
    
    // usage:
    nrf_clock_lf_src_set((nrf_clock_lfclk_t)CLOCK_CONFIG_LF_SRC);

    Don't want XTAL otherwise you lose the io on pins P0.0 and P0.1

  • I wrote it :-) I always check the port setting of every pin as a diagnostic log. Tedious, but many peripherals can be mapped to a pin, example:

        if (NRF_SPI2->PSEL.SCK  == PinId) return "SPI2 SCK";
        if (NRF_SPI2->PSEL.MOSI == PinId) return "SPI2 MOSI";
        if (NRF_SPI2->PSEL.MISO == PinId) return "SPI2 MISO";

    Running all 32 pins through a tree of such statements allows a report on pin status (in/out/etc) and mapping, especially when the map shouldn't.

  • I will give that a go, thanks so much for the help.  Will post if I get it fixed via your help.

  • I suggest using the SDK API.  Doing it at the register level may cause forgetting to set something up.  The API takes care of multiple settings automatically.  Maybe you are more used to do it at the register level (as most TI CCxxxx examples do), but that opens up more chances of making mistakes.  That was one of the reasons I moved from TI CCxxx BLE to Nordic nRF5xxxx BLE.  The SDKs are so much better.

    As far as not getting interrupts, it definitely could be sdk_config.h settings.  Either not enabling the correct SPI items or maybe you will need to enable/disable settings for debug/NRF_LOG/etc as they may interfere with the timing.

    Good luck. Slight smile

Reply
  • I suggest using the SDK API.  Doing it at the register level may cause forgetting to set something up.  The API takes care of multiple settings automatically.  Maybe you are more used to do it at the register level (as most TI CCxxxx examples do), but that opens up more chances of making mistakes.  That was one of the reasons I moved from TI CCxxx BLE to Nordic nRF5xxxx BLE.  The SDKs are so much better.

    As far as not getting interrupts, it definitely could be sdk_config.h settings.  Either not enabling the correct SPI items or maybe you will need to enable/disable settings for debug/NRF_LOG/etc as they may interfere with the timing.

    Good luck. Slight smile

Children
No Data
Related