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

nrf51822 ADC enable means what?

Is enable required before configuration? Does toggling NRF_ADC->ENABLE reset the configuration (like it does for the radio?) Is the power to the ADC automatic, so that even if enabled, it might be quiescent current?

The product spec, register description for NRC_ADC->ENABLE is a tautology: "Enabled" in one column equals "Enabled" in another column. The second column should describe what enabled means.

Somewhere I read that enable means "acquire the configured input channel". Do you need to enable ADC (to acquire input channel) if input selection is disabled? Before every read?

The sequence of calls that I am using is: enable; spinOnNotBusy; config; clearEndEvent; start; spinOnEndEvent; read; clearEndEvent; start; spinOnEndEvent; .... (not using PPI or interrupts or SD, just occasionally reading Vcc/3 with ref VBG.)

Another thread said a 1ms delay was necessary.

For me, it always reads zero.

  • Hi,

    If the peripheral is disabled, it should not draw any current. You can read more about the power modes in nRF5x in this thread. Toggling the ENABLE register will not reset the configuration.

    The register description shows the various values and it's effect. Setting NRF_ADC->ENABLE to 1 will enable the ADC peripheral. Setting it to 0 will diable the peripheral.

    You should give some references to the statements you post here, as it is hard to get context from "Somewhere I read" and "Another thread said". The peripheral needs to be enabled to aquire the configured pin, but you only need to enable it once. Then you can trigger the START task multiple times. If you have disabled inputs, you won't be able to aquire any inputs, so the value of the ENABLE register should not matter. When a conversion is in progress, the ADC peripheral will enter a BUSY state, which can be monitored by the BUSY register. You don't need any additional delays, except making sure the ADC is not busy then triggering the samling/conversion.

    Best regards,

    Jørgen

  • For me, the question is moot. I now use the HAL, rather than try to understand low level ADC on an old chip.

    "Setting NRF_ADC->ENABLE to 1 will enable the ADC peripheral" has low info content. IMO the docs should say something like "after the ADC is enabled, any configured input pin is acquired (but other peripherals can mistakenly share the pin?). The ADC can be configured at any time, but should be enabled again after a config change of the input selection" (I am not sure that is right?) IMO the docs should give an algebra of valid and invalid sequences ( complicated, involving events from other peripherals acquiring the pin?) In the HAL code: nrf_adc_convert_single(INPUT_DISABLED) calls nrf_adc_select_input(INPUT_DISABLED) which has code to disable the ADC, just before starting a sample !!! "value of ENABLE does not matter": it samples an ADC which is not enabled!

  • Trying to express myself more clearly and succinctly: "enabled" usually means "able to be used", but in this case it seems to me to mean something else, if it is true that you can sample the ADC when the ENABLE bit is clear, when input pins are not selected.

Related