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

How to use GPIO 09, GPIO 10 nrf52840 as GPIO interrupt

Dear support team,

I would like to use GPIO 09/10 as a GPIO interrupt.

I just searched and I see that need to define CONFIG_NFCT_PINS_AS_GPIOS.

But I can't do it. Please help!

P/s: I use nrf52840 with segger embedded.

Thanks and regards,

John N

Parents
  • Why can't you define CONFIG_NFCT_PINS_AS_GPIOS?

    Nevertheless, if for some reason you cannot define CONFIG_NFCT_PINS_AS_GPIOS you can run the code it would trigger by yourself

    	// Making sure the NFC pins are set as GPIO
    	if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk)
    			== (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)) {
    		NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
    		while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
    		}
    		NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
    		while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
    		}
    		NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
    		while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {
    		}
    		NVIC_SystemReset();
    	}

  • Hi,

    my application is config GPIO 10 as GPIO interrupt. I already defined CONFIG_NFCT_PINS_AS_GPIOS in Preprocessor Definitions as you refer.
    This is my code. Could you help me check it?

    P/S; macro FLOW_SS_PIN_INPUT is defined as GPIO 10

    static void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    { 
        test_adc = true;
        flow_cnt ++;
        FLOW_DBG(TAG, "cnt = %d\r\n", flow_cnt);
    }
    
    void flow_sensor_init(void)
    {
      ret_code_t err_code;
      
        if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk)== (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos))
        {
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NVIC_SystemReset();
        }
    
      //init gpioe
      err_code = nrf_drv_gpiote_init();
      APP_ERROR_CHECK(err_code);
    
      //init input
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
      in_config.pull = NRF_GPIO_PIN_PULLUP;
    
      err_code = nrf_drv_gpiote_in_init(FLOW_SS_PIN_INPUT, &in_config, in_pin_handler);
      APP_ERROR_CHECK(err_code);
    
      nrf_drv_gpiote_in_event_enable(FLOW_SS_PIN_INPUT, true);
    
    }
    

Reply
  • Hi,

    my application is config GPIO 10 as GPIO interrupt. I already defined CONFIG_NFCT_PINS_AS_GPIOS in Preprocessor Definitions as you refer.
    This is my code. Could you help me check it?

    P/S; macro FLOW_SS_PIN_INPUT is defined as GPIO 10

    static void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    { 
        test_adc = true;
        flow_cnt ++;
        FLOW_DBG(TAG, "cnt = %d\r\n", flow_cnt);
    }
    
    void flow_sensor_init(void)
    {
      ret_code_t err_code;
      
        if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk)== (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos))
        {
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
            while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
            NVIC_SystemReset();
        }
    
      //init gpioe
      err_code = nrf_drv_gpiote_init();
      APP_ERROR_CHECK(err_code);
    
      //init input
      nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
      in_config.pull = NRF_GPIO_PIN_PULLUP;
    
      err_code = nrf_drv_gpiote_in_init(FLOW_SS_PIN_INPUT, &in_config, in_pin_handler);
      APP_ERROR_CHECK(err_code);
    
      nrf_drv_gpiote_in_event_enable(FLOW_SS_PIN_INPUT, true);
    
    }
    

Children
No Data
Related