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

clear external interrupt

link text from this post i am generating interrupt using button 3. when i push my button,interrupt generates,LED turn on. but after turning on LED, i want to clear interrupt. so LED become off.here i don't want to use nrf_drv_gpiote_out_toggle(); function. my code is here

void gpiote_evt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    switch(action)
    {
       case NRF_GPIOTE_POLARITY_HITOLO:
			
			 nrf_drv_gpiote_out_clear(LED_3);	
            break;
        default:
            
            break;
    }
} 
  • int main(void) { uint32_t err_code; bool erase_bonds; ret_code_t ret_code;

            // Initialize.
         
            ble_stack_init();
            gap_params_init();
            services_init();
            advertising_init();
        	advertising_start();
            conn_params_init();
            
           
           
             ret_code = nrf_drv_gpiote_init();
           // APP_ERROR_CHECK(ret_code);
            
            // Configure LED_1 pin as output
            nrf_drv_gpiote_out_config_t led_config = GPIOTE_CONFIG_OUT_TASK_LOW;
            
            // Initialize LED_1 pin as output
            ret_code =  nrf_drv_gpiote_out_init(LED_3, &led_config);
          //  APP_ERROR_CHECK(ret_code);
        	    nrf_drv_gpiote_in_config_t config =
            {
                .sense = NRF_GPIOTE_POLARITY_HITOLO,
        			//.sense = NRF_GPIOTE_POLARITY_LOTOHI,
                .pull = NRF_GPIO_PIN_PULLUP , // NRF_GPIO_PIN_NOPULL
        		//.pull = NRF_GPIO_PIN_NOPULL ,
                .is_watcher = false,
                .hi_accuracy = false
            };
                
            // Initialize Interrupt Pin
            ret_code = nrf_drv_gpiote_in_init(INTERRUPT_PIN, &config, gpiote_evt_handler);
          APP_ERROR_CHECK(ret_code);
            
            // Enable Interrupts from interrupt pin
           nrf_drv_gpiote_in_event_enable(INTERRUPT_PIN,true);
            // Enter main loop.
            while(true)
            { 
               	
            }
    
    }
    
  • can you tell me how to clear interrupt automatically?

  • The leds on the nRF51 DK are active low, i.e. if the LED pin is high the led is OFF and if the LED pin is low the led is ON. This means that you have to use nrf_drv_gpiote_out_set(LED_3) to turn off the led.

  • i know that. but i want to clear interrupt automatically.

  • when i press button. interrupt generates and LED become on.but i want when button returns to its normal position LED become off. i don't want to use toggle function

1 2 3 4 5