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

COMP and external reference

Hi,

I'm trying to compare two RC networks by using GPIOTE, PPI, a Timer and the comparator to measure the time needed for a charge and discharge cycle for each of the networks and then comparing the values.

At the moment I'm using the comparator in single ended mode with VDD as reference and this is working, but the results are pretty noisy. Part of the noise is obviously coming from the reference voltage, because doing the measurements inside a high priority timeslot is reducing the noise significantly.

For further improvements I want to supply VDD externally to AIN0 through a low pass filter (1.2kOhm, 2.2uF), but after changing the reference from NRF_COMP_REF_VDD to NRF_COMP_REF_ARef and ext_ref to NRF_COMP_EXT_REF_0 the output of the comparator is always zero.

Is there anything else to do or enable to use an external reference?

  • Hi Thomas

    A few questions from my side: Are you using the comp in single or differential mode? What is your hysteresis setting? Do you have ISOURCE enabled? Have you tried both AIN0 and AIN1 for the reference input?

  • Hi Stefan

    I'm using the comp in single ended mode, ISOURCE and is off, the behaviour is the same on both reference input pins. Hysteresis is off, too, the threshold voltage is reconfigured after up events to measure the time needed to charge the capacitor from 24/64Vin up to 40/64Vin and discharge back to 24/64*Vin.

    I did some further testing with different input voltages on the reference input. The output is not always zero, but with REFSEL set to 7 the comparator seems to be always in differential mode, regardless of the setting in the MODE register.

  • Hi Thomas

    I am trying this using the nrf_drv_comp driver. It seems I experience the same things as you, if I set the comparator to external reference, the settings in the TH register do not seem to work. As you said, it seems like the comp is in differential mode. I need to do further verification to see if this is a hardware bug. At this point I see no way around this.

  • Hi Stefan Thanks for the confirmation, for now I will keep using the internal VDD as reference and try to manage the noise with filtering by software.

  • Good idea! It has been confirmed that there is in fact a hardware bug in COMP peripheral when using external reference in single mode. No workaround reported yet.