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

52820 COMP problem

Dear sir, 

        I have a light sensor connected to P0.04/AIN2 on 52820. How can i get the change of voltage?

        I use the COMP, and has enabled COMP_ENABLED in sdk_config.h, compiled successfully and can run on board, but comp_event_handler does not be called when light changed.

        The code like follow. Does any wrong? Thank you!

#include "nrf_drv_comp.h"
void comp_event_handler(nrf_comp_event_t evt)
{
        NRF_LOG_INFO("#############comp_event_handler#####");
}

void COMP_TEST()
{
        uint32_t err_code;
        nrf_drv_comp_config_t comp_config = NRF_DRV_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_2);
        err_code = nrf_drv_comp_init(&comp_config, comp_event_handler);
        nrf_drv_comp_start(NRF_DRV_COMP_EVT_EN_CROSS_MASK ,NRFX_COMP_SHORT_STOP_AFTER_CROSS_EVT);

        while (true)
        {
                idle_state_handle();
        }
}

        

Parents
  • The defines in sdk_config.h is:

    #define NRFX_COMP_ENABLED 1

    #define NRFX_COMP_CONFIG_REF 4 // <4=> VDD 3.3v

    #define NRFX_COMP_CONFIG_MAIN_MODE 0 // <0=> Single ended 

    #define NRFX_COMP_CONFIG_INPUT 2

    And I also modify the hreshold default configuration:

    /** @brief COMP threshold default configuration. */
    #define NRFX_COMP_CONFIG_TH \
    { \
    .th_down = NRFX_VOLTAGE_THRESHOLD_TO_INT(1.0, 3.3), \
    .th_up = NRFX_VOLTAGE_THRESHOLD_TO_INT(2.0, 3.3) \
    }

    But when the voltage down to 0.3V from 2.5V , the comp_event_handler didn't be called? 

  • Hi, 

    Are you using your a custom board or a development kit? If you're using a custom board, have you included a custom board file? What pin are you measuring on?

    regards

    Jared

Reply Children
No Data
Related