Interrupt routine not working as intended. Did I do setup wrong?

Hello. I have a custom board with a digital sensor that gives a data-packet once every 8 seconds approximately. I have set up my code to enter an interrupt when a positive flank is received from the sensor. After the datapacket has been read, the receiving GPIO is first set to low output for 0.5 seconds and then set to high impedance input. After that I want the NRF to wait for the next positive flank on this GPIO from the sensor.

This seems to work for the most part. But sometimes, seemingly random, the NRF doesn't react on the received positive flank, and the NRF stays in the background-while loop. In the picture below I have measured on the GPIO which receives the data packet. On the left there is a data-packet which the ISR reacted on correctly. But for the next positive flank, the NRF did nothing. I suspect there is something wrong with my interrupt setup.

Below you can check my setup code for the interrupt. Is there anything you can see that is wrong or missing?

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{

    
    nrf_drv_gpiote_in_event_disable(PIN_IN);

    nrf_drv_gpiote_in_uninit(PIN_IN);

    readlowpowerpyro(); // Read data packet from sensor
 
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;

    ret_code_t err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
    

  //  __WFE();
  //  __SEV();
  // __WFE();

}

static void gpio_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;

    err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_IN, true);
}

Here is the code for setting the GPIO to low output for 0.5 seconds and then to high impedance, making it ready to receive the next datapacket.

  nrf_gpio_pin_clear(PIN_IN);
  nrf_gpio_cfg_output(PIN_IN);
  nrf_delay_us(500);
  nrf_gpio_cfg_input(PIN_IN,NRF_GPIO_PIN_NOPULL);

Parents
  • Hi,

    I'm not sure I follow correctly the flow of your application. Could you include the full main.c file for better understanding?

    Do you use the same pin for interrupt and for reading the datapacket, and for outputting a signal?

    Are you testing this with a minimal application, without any other peripherals running, or could there be some other interrupt handling preventing/delaying the handling of the pin interrupt?

    if(PIN_IN) will always be true, since this is the pin number (which is higher than zero). If your intention was to read the pin state, you need to use the nrf_drv_gpiote_in_is_set() API or similar GPIO HAL function.

    Best regards,
    Jørgen

  • Can you read out the values of the GPIO and GPIOTE peripheral registers when this issue occurs?

    When this happens, are you stuck in the state where the interrupt does not happen if a new pulse is generated on the input, or will the issue resort itself after some time?

    I could not see any obvious issues in the code (apart from the unnecessary call to nrf_drv_gpiote_init() inside if(nrf_gpio_pin_read(PIN_IN)) where the return code is not checked, but since this is not part of your original code, I do not expect this to be an issue).

  • When it happens I am stuck in this state until i have performed "nrf_drv_gpiote_in_uninit(PIN_IN);" inside of the while-loop. If I dont do "nrf_drv_gpiote_in_uninit(PIN_IN);" then the GPIO stays high forever since the positive flank (from the sensor) has set the GPIO high, and the GPIO is stuck in its "high Z state". 

    I cant see the GPIO registers during debug for some reason. Here are the GPIOTE registers:

  • Now I see it's all just 0. Not sure how to read the register values out.

  • Hi,

    The register values should update if you pause the application execution by clicking the pause symbol in the debug controls. If not, you can also read out the entire registers using nrfjprog:

    # Read GPIOTE:
    nrfjprog --memrd 0x40006000 --n 0x1000
    
    # Read GPIO (P0):
    nrfjprog --memrd 0x50000000 --n 0x1000

    The GPIO registers should also be accessible in the debug viewer, but it is likely named P0 and not GPIO, since the nRF52 series can support multiple GPIO ports.

    nicsam1992 said:
    When it happens I am stuck in this state until i have performed "nrf_drv_gpiote_in_uninit(PIN_IN);" inside of the while-loop. If I dont do "nrf_drv_gpiote_in_uninit(PIN_IN);" then the GPIO stays high forever since the positive flank (from the sensor) has set the GPIO high, and the GPIO is stuck in its "high Z state". 

    Is there any possibility to trigger a new pulse on the input by shorting the pin/pad to VDD, to see if this triggers the interrupt again (just for debugging purposes)?

    Best regards,
    Jørgen

  • Ok, there is the register info:

    GPIOTE                                              
        TASKS_OUT[0]                      0x40006000    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[1]                      0x40006004    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[2]                      0x40006008    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[3]                      0x4000600c    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[4]                      0x40006010    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[5]                      0x40006014    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[6]                      0x40006018    
            TASKS_OUT                     [0:0]         
        TASKS_OUT[7]                      0x4000601c    
            TASKS_OUT                     [0:0]         
        TASKS_SET[0]                      0x40006030    
            TASKS_SET                     [0:0]         
        TASKS_SET[1]                      0x40006034    
            TASKS_SET                     [0:0]         
        TASKS_SET[2]                      0x40006038    
            TASKS_SET                     [0:0]         
        TASKS_SET[3]                      0x4000603c    
            TASKS_SET                     [0:0]         
        TASKS_SET[4]                      0x40006040    
            TASKS_SET                     [0:0]         
        TASKS_SET[5]                      0x40006044    
            TASKS_SET                     [0:0]         
        TASKS_SET[6]                      0x40006048    
            TASKS_SET                     [0:0]         
        TASKS_SET[7]                      0x4000604c    
            TASKS_SET                     [0:0]         
        TASKS_CLR[0]                      0x40006060    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[1]                      0x40006064    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[2]                      0x40006068    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[3]                      0x4000606c    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[4]                      0x40006070    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[5]                      0x40006074    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[6]                      0x40006078    
            TASKS_CLR                     [0:0]         
        TASKS_CLR[7]                      0x4000607c    
            TASKS_CLR                     [0:0]         
        EVENTS_IN[0]        0x00000000    0x40006100    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[1]        0x00000000    0x40006104    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[2]        0x00000000    0x40006108    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[3]        0x00000000    0x4000610c    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[4]        0x00000000    0x40006110    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[5]        0x00000000    0x40006114    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[6]        0x00000000    0x40006118    
            EVENTS_IN       0             [0:0]         
        EVENTS_IN[7]        0x00000000    0x4000611c    
            EVENTS_IN       0             [0:0]         
        EVENTS_PORT         0x00000000    0x4000617c    
            EVENTS_PORT     0             [0:0]         
        INTENSET            0x80000001    0x40006304    
            IN0             1             [0:0]         
            IN1             0             [1:1]         
            IN2             0             [2:2]         
            IN3             0             [3:3]         
            IN4             0             [4:4]         
            IN5             0             [5:5]         
            IN6             0             [6:6]         
            IN7             0             [7:7]         
            PORT            1             [31:31]       
        INTENCLR            0x80000001    0x40006308    
            IN0             1             [0:0]         
            IN1             0             [1:1]         
            IN2             0             [2:2]         
            IN3             0             [3:3]         
            IN4             0             [4:4]         
            IN5             0             [5:5]         
            IN6             0             [6:6]         
            IN7             0             [7:7]         
            PORT            1             [31:31]       
        CONFIG[0]           0x00011001    0x40006510    
            MODE            1             [1:0]         
            PSEL            0x10          [12:8]        
            POLARITY        1             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[1]           0x00000000    0x40006514    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[2]           0x00000000    0x40006518    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[3]           0x00000000    0x4000651c    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[4]           0x00000000    0x40006520    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[5]           0x00000000    0x40006524    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[6]           0x00000000    0x40006528    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
        CONFIG[7]           0x00000000    0x4000652c    
            MODE            0             [1:0]         
            PSEL            0x00          [12:8]        
            POLARITY        0             [17:16]       
            OUTINIT         0             [20:20]       
    P0                                                  
        OUT                 0x00040000    0x50000504    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           0             [12:12]       
            PIN13           0             [13:13]       
            PIN14           0             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        OUTSET              0x00040000    0x50000508    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           0             [12:12]       
            PIN13           0             [13:13]       
            PIN14           0             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        OUTCLR              0x00040000    0x5000050c    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           0             [12:12]       
            PIN13           0             [13:13]       
            PIN14           0             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        IN                  0x00210000    0x50000510    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           0             [12:12]       
            PIN13           0             [13:13]       
            PIN14           0             [14:14]       
            PIN15           0             [15:15]       
            PIN16           1             [16:16]       
            PIN17           0             [17:17]       
            PIN18           0             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           1             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        DIR                 0x00045000    0x50000514    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           1             [12:12]       
            PIN13           0             [13:13]       
            PIN14           1             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        DIRSET              0x00045000    0x50000518    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           1             [12:12]       
            PIN13           0             [13:13]       
            PIN14           1             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        DIRCLR              0x00045000    0x5000051c    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           1             [12:12]       
            PIN13           0             [13:13]       
            PIN14           1             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           1             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        LATCH               0x00000000    0x50000520    
            PIN0            0             [0:0]         
            PIN1            0             [1:1]         
            PIN2            0             [2:2]         
            PIN3            0             [3:3]         
            PIN4            0             [4:4]         
            PIN5            0             [5:5]         
            PIN6            0             [6:6]         
            PIN7            0             [7:7]         
            PIN8            0             [8:8]         
            PIN9            0             [9:9]         
            PIN10           0             [10:10]       
            PIN11           0             [11:11]       
            PIN12           0             [12:12]       
            PIN13           0             [13:13]       
            PIN14           0             [14:14]       
            PIN15           0             [15:15]       
            PIN16           0             [16:16]       
            PIN17           0             [17:17]       
            PIN18           0             [18:18]       
            PIN19           0             [19:19]       
            PIN20           0             [20:20]       
            PIN21           0             [21:21]       
            PIN22           0             [22:22]       
            PIN23           0             [23:23]       
            PIN24           0             [24:24]       
            PIN25           0             [25:25]       
            PIN26           0             [26:26]       
            PIN27           0             [27:27]       
            PIN28           0             [28:28]       
            PIN29           0             [29:29]       
            PIN30           0             [30:30]       
            PIN31           0             [31:31]       
        DETECTMODE          0x00000000    0x50000524    
            DETECTMODE      0             [0:0]         
        PIN_CNF[0]          0x00000002    0x50000700    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[1]          0x00000002    0x50000704    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[2]          0x00000002    0x50000708    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[3]          0x00000002    0x5000070c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[4]          0x00000002    0x50000710    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[5]          0x00000002    0x50000714    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[6]          0x00000002    0x50000718    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[7]          0x00000002    0x5000071c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[8]          0x00000002    0x50000720    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[9]          0x00000002    0x50000724    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[10]         0x00000002    0x50000728    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[11]         0x00000002    0x5000072c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[12]         0x00000003    0x50000730    
            DIR             1             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[13]         0x00000002    0x50000734    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[14]         0x00000003    0x50000738    
            DIR             1             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[15]         0x00000002    0x5000073c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[16]         0x00000000    0x50000740    
            DIR             0             [0:0]         
            INPUT           0             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[17]         0x00000002    0x50000744    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[18]         0x00000003    0x50000748    
            DIR             1             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[19]         0x00000002    0x5000074c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[20]         0x00000002    0x50000750    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[21]         0x00000002    0x50000754    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[22]         0x00000002    0x50000758    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[23]         0x00000002    0x5000075c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[24]         0x00000002    0x50000760    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[25]         0x00000002    0x50000764    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[26]         0x00000002    0x50000768    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[27]         0x00000002    0x5000076c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[28]         0x00000002    0x50000770    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[29]         0x00000002    0x50000774    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[30]         0x00000002    0x50000778    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       
        PIN_CNF[31]         0x00000002    0x5000077c    
            DIR             0             [0:0]         
            INPUT           1             [1:1]         
            PULL            0             [3:2]         
            DRIVE           0             [10:8]        
            SENSE           0             [17:16]       

    I am able to trigger a new pulse like you said. Then it works again for some time, until a pulse is ignored and the NRF gets stuck again in the same way.

Reply Children
  • nicsam1992 said:
    I am able to trigger a new pulse like you said. Then it works again for some time, until a pulse is ignored and the NRF gets stuck again in the same way.

    Sounds like the nRF is configured correctly when exiting the event handler then. Have you verified that the next pulse does not arrive before the current interrupt handler is completed? You have some quite long delays in there. If the next pulse arrives before the event is cleared and the interrupt handler is completed, a new interrupt may not be triggered. You can check this by toggling a second GPIO when entering/exiting the handler, and scope this along with the interrupt trigger signal.

    Ideally, I would recommend you to reduce the time spent in the interrupt handler, and perform the lengthy delays in the main context:

    nrf_gpio_pin_set(LED);
    nrf_delay_ms(1000);
    nrf_gpio_pin_clear(LED);
    nrf_delay_ms(1000);

  • This seems to solve the problem! Thank you! I was not expecting this because the sensor is configured to send pulses only once every 8 seconds. But I moved all delays to the main context and now it seems to work all the time. 

Related