This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can I really not use LPCOMP and ADC at the same time?

In the "NRF51 Series Reference Manual" (v3.0) it states:

The LPCOMP shares registers and other resources with peripherals that have the same ID as the LPCOMP.
You must disable all peripherals that have the same ID as the LPCOMP before the LPCOMP
can be configured and used. Disabling a peripheral that has the same ID as the LPCOMP will
not reset any of the registers that are shared with the LPCOMP. Therefore, it is important to
configure all relevant LPCOMP registers explicitly to secure that it operates correctly.

See the Instantiation table in Instantiation on page 17 for details on peripherals and their IDs.

    Note: The LPCOMP is using the same analog pins as the ADC. The ADC must be disabled
    before the LPCOMP can be enabled.

And a bit before it states:

The selected analog pins will be acquired by the LPCOMP when it is enabled through the
ENABLE register.

So, from the documentation I see:

  • ADC and LPCOMP do not share the same ID. So that is not a reason to disable ADC...
  • Only selected analog pins will be acquired by LPCOMP, so we can use other pins for the ADC...
  • ADC must be disabled completely...

What exactly is shared between LPCOMP and ADC? Is the mux for PSEL shared for example? Or can I only not use AIN0 when I use it already for ADC (which would be logical)? Or is it that I cannot do any LPCOMP stuff when I am doing ADC on a totally different pin?

  • Hi

    As far as I know, the PSEL MUX is shared. I learned this the hard way when I was trying to monitor voltage with LPCOMP on an AIN pin and sampling with the ADC on another AIN pin. I could enable both of them but the ADC output did not make sense and the LPCOMP did not trigger on the right voltage level.

    If I am correct that only the PSEL MUX is shared, then you should be able to measure battery voltage with the ADC while monitoring voltage on AIN pin with the LPCOMP. I have not tried this yet.

    I will seek confirmation on that only PSEL MUX is shared with ADC and LPCOMP, and update this thread otherwise.

    There is a LPCOMP example available on this thread, ADC examples are available on Nordic's Github

    Update 3.12.2014 I have done some testing, seems like the MUX is shared and nothing else. In my test code, I have monitored voltage level on AIN4 pin with LPCOMP and sampled on AIN6 with the ADC at the same time. The higher of the two input voltages will be input to both LPCOMP and ADC. For example if I have 0.6V on AIN6 and 1.5V on AIN4, 1.5V will be input to both LPCOMP and ADC. If I however use the ADC only to sample the supply voltage, i.e. not from AIN pin, then both LPCOMP and ADC work fine.

    I include my test code below, which in current state seems to work fine with ADC sampling supply voltage and LPCOMP monitoring voltage on AIN4. I have tested it with nRF51 SDK v6.1.0 and the nRF51822 development kit.

    ADC_and_LPCOMP_test.zip

    Update 4.12.2014 The designer has confirmed that my findings are as expected. Only the PSEL MUX is shared, so it should be safe to use ADC for battery monitoring while using LPCOMP at the same time.

  • Thanks! It might indeed be that the PSEL MUX is the only thing shared. That would be nice. I personally don't think the LPCOMP is implemented using ADC circuitry, but who knows... Awaiting your experiment! :-)

Related