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

turning off qdec led

In the nrf52 specification:

"The Phase A, Phase B, and LED signals are mapped to physical pins according to the configuration specified in the PSEL.A, PSEL.B, and PSEL.LED registers respectively. If the CONNECT field value 'Disconnected' is specified in any of these registers, the associated signal will not be connected to any physical pin."

There doesn't seem to be an obvious wrapper for this in the sdk. How do I access the PSEL.LED connect field to disable the LED?

Thank you

Parents
  • Hi,

    Like this

        nrf_drv_qdec_config_t qdec_cfg = 
        {
            .reportper = NRF_QDEC_REPORTPER_10,             /**< Report period in samples. */
            .sampleper = NRF_QDEC_SAMPLEPER_128us,         /**< Sampling period in microseconds. */
            .psela = GPIO_INPUT_A,                          /**< Pin number for A input. */
            .pselb = GPIO_INPUT_B,                          /**< Pin number for B input. */
            .pselled = GPIO_INPUT_LED,                      /**< Pin number for LED output. */
            .ledpre = 10,                                   /**< Time (in microseconds) how long LED is switched on before sampling. */
            .ledpol = 0,                                    /**< Active LED polarity. */
            .dbfen = false,                                 /**< State of debouncing filter. */
            .sample_inten = true,                           /**< Enabling sample ready interrupt. */
            .interrupt_priority = 3,                        /**< QDEC interrupt priority. */
        };
        
        err_code = nrf_drv_qdec_init(&qdec_cfg, qdec_event_handler);
        APP_ERROR_CHECK(err_code);
        
        // Needed for my quad enc. as I have no external pulls
        nrf_gpio_cfg_input(qdec_cfg.pselb,NRF_GPIO_PIN_PULLUP);
        nrf_gpio_cfg_input(qdec_cfg.psela,NRF_GPIO_PIN_PULLUP);
        nrf_drv_qdec_enable();
        
        while (true)
        {
            __WFI();
        }
    

    Here you can set .pselled to whatever you like, for example disconnected.

    Best regards,

    Øyvind

Reply
  • Hi,

    Like this

        nrf_drv_qdec_config_t qdec_cfg = 
        {
            .reportper = NRF_QDEC_REPORTPER_10,             /**< Report period in samples. */
            .sampleper = NRF_QDEC_SAMPLEPER_128us,         /**< Sampling period in microseconds. */
            .psela = GPIO_INPUT_A,                          /**< Pin number for A input. */
            .pselb = GPIO_INPUT_B,                          /**< Pin number for B input. */
            .pselled = GPIO_INPUT_LED,                      /**< Pin number for LED output. */
            .ledpre = 10,                                   /**< Time (in microseconds) how long LED is switched on before sampling. */
            .ledpol = 0,                                    /**< Active LED polarity. */
            .dbfen = false,                                 /**< State of debouncing filter. */
            .sample_inten = true,                           /**< Enabling sample ready interrupt. */
            .interrupt_priority = 3,                        /**< QDEC interrupt priority. */
        };
        
        err_code = nrf_drv_qdec_init(&qdec_cfg, qdec_event_handler);
        APP_ERROR_CHECK(err_code);
        
        // Needed for my quad enc. as I have no external pulls
        nrf_gpio_cfg_input(qdec_cfg.pselb,NRF_GPIO_PIN_PULLUP);
        nrf_gpio_cfg_input(qdec_cfg.psela,NRF_GPIO_PIN_PULLUP);
        nrf_drv_qdec_enable();
        
        while (true)
        {
            __WFI();
        }
    

    Here you can set .pselled to whatever you like, for example disconnected.

    Best regards,

    Øyvind

Children
No Data
Related