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
  • Hello,

    Thank you for your patience with this.

    You are correct that the startup of the COMP peripheral might take some time, but subsequent sampling (following the READY event) will adhere to the propagation delay for each speed mode, as listed in the electrical specifications. If you do not stop the COMP after this it will be ready for sampling, which you may trigger with the TASKS_SAMPLE task through PPI.

    Could you share some more of the code in which you use this COMP? Do I understand you correctly that you are stopping the COMP peripheral inbetween each sampling, and starting it each time a pulse is detected on a pin?

    Best regards,
    Karl

  • Thank you for reply.

    Yes, I start the COMP, sample and stop in a signal processing period, because I found that doing so has less power consumption than always leaving the COMP starting (not stoping it). My signal input rate is 10Hz, which means the rate I start the COMP and stop it is 10Hz in this case.

    I also found that the startup of COMP peripheral takes about 60us? the tINT_REF,START (Startup time for the internal bandgap reference, 50-80us) is involved in the COMP startup process. is this correct? 

    Thank you.

Reply
  • Thank you for reply.

    Yes, I start the COMP, sample and stop in a signal processing period, because I found that doing so has less power consumption than always leaving the COMP starting (not stoping it). My signal input rate is 10Hz, which means the rate I start the COMP and stop it is 10Hz in this case.

    I also found that the startup of COMP peripheral takes about 60us? the tINT_REF,START (Startup time for the internal bandgap reference, 50-80us) is involved in the COMP startup process. is this correct? 

    Thank you.

Children
Related