nano ble 33 - configure adc reference to gain of 6

For the nano ble 33, the analogReference function limits you to a 4x gain (AR_INTERNAL2V4) for an input range of 0 to 2.4v. However, from what I read in the nRF52840 data sheet there is a configuration option to set the gain to 6 for an input range of 0 to 3.6 volts. Can someone help point me in a direction or method to enable me to configure the ADC input for a gain of 6? I tired to search the arduino source code but I could not find anything meaningful. I did find something in wiring_analog.c that I don't understand:

uint8_t analog_reference = DEFAULT;

void analogReference(uint8_t mode)
// can't actually set the register here because the default setting
// will connect AVCC and the AREF pin, which would cause a short if
// there's something connected to AREF.
analog_reference = mode;

Any help or suggestions would be appreciated.


After looking around a little bit more at the source do you think something like this will work?

nrf_saadc_reference_t reference = NRF_SAADC_REFERENCE_INTERNAL;
nrf_saadc_gain_t gain = NRF_SAADC_GAIN1_6;
adcCurrentConfig.reference = reference;
adcCurrentConfig.gain = gain;

any thoughts

I gave it try with two AAA batteries in series and it seems like it's working:

Analog read: 898, Volts = 3.16
Analog read: 890, Volts = 3.13
Analog read: 890, Volts = 3.13
Analog read: 896, Volts = 3.15
Analog read: 896, Volts = 3.15
Analog read: 892, Volts = 3.14

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.