How to implement a blinking LED for P1.09 GPIO Pin in NRF52840 Controller

Hi ,

I am working on NRF52840 microcontroller, I want to implement blinky LED for P1.09 GPIO pin, can you please tell me, how to  implement that. 

Thanks

Parents
  • Based on your case history, I guess you are working on the nRF5 SDK, and not NCS. Is that correct? I will assume it is until you say otherwise. For future cases, please specify what SDK type and version you are using.

    To set P1.09 as an output, you can use the following implementation:

    #define MY_GPIO NRF_GPIO_PIN_MAP(1, 9)
    
    void main(int)
    {
        ret_code_t err_code;
        
        nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
        err_code = nrf_drv_gpiote_out_init(MY_GPIO, &out_config);
        APP_ERROR_CHECK(err_code);
        
        nrf_drv_gpiote_out_clear(MY_GPIO);
        nrf_drv_gpiote_out_toggle(MY_GPIO);
        nrf_drv_gpiote_out_set(MY_GPIO);
    }

    Best regards,

    Edvin

Reply
  • Based on your case history, I guess you are working on the nRF5 SDK, and not NCS. Is that correct? I will assume it is until you say otherwise. For future cases, please specify what SDK type and version you are using.

    To set P1.09 as an output, you can use the following implementation:

    #define MY_GPIO NRF_GPIO_PIN_MAP(1, 9)
    
    void main(int)
    {
        ret_code_t err_code;
        
        nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
        err_code = nrf_drv_gpiote_out_init(MY_GPIO, &out_config);
        APP_ERROR_CHECK(err_code);
        
        nrf_drv_gpiote_out_clear(MY_GPIO);
        nrf_drv_gpiote_out_toggle(MY_GPIO);
        nrf_drv_gpiote_out_set(MY_GPIO);
    }

    Best regards,

    Edvin

Children
Related