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

How long does the COMP (comparator) take to finish a sample?

Hello,

I use nRF52832's  COMP (comparator) to sample a pulse signal's voltage level.

I found when the pusle width is below like about 60us, the COMP can't get correct result, however, when the pulse width is longer than 60us, the COMP can get correct result.

I use "nrf(x)_comp_sample()" API of SDK 17.02 to do the job.

The COMP init code is like this:

static void comp_init(void)
{
    ret_code_t err_code;
    nrf_drv_comp_config_t m_comp_config = NRF_DRV_COMP_DEFAULT_CONFIG(NRF_COMP_INPUT_3);

    /* Workaround for Errata 12 "COMP: Reference ladder is not correctly calibrated" */
    *(volatile uint32_t *)0x40013540 = (*(volatile uint32_t *)0x10000324 & 0x00001F00) >> 8;

	m_comp_config.reference = NRF_COMP_REF_Int1V2;
	m_comp_config.threshold.th_down = VOLTAGE_THRESHOLD_TO_INT(0.8, 1.2);
	m_comp_config.threshold.th_up = VOLTAGE_THRESHOLD_TO_INT(1.0, 1.2);
	m_comp_config.speed_mode = NRF_COMP_SP_MODE_Low;

    err_code = nrf_drv_comp_init(&m_comp_config, comp_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_comp_shorts_disable(UINT32_MAX);
    nrf_comp_int_disable(UINT32_MAX);
}

CPU is calling "nrf_drv_comp_sample();" to do the sample job.

The datasheet says the propagation delay in low-power mode takes 0.6us, I wonder what's wrong with the code?

Please share any thoughts, thanks in advance!

Parents Reply Children
No Data
Related