nRF: Change analog reference to VCC(/4)

@ladyada says:
"having this be adjustable (reference) would be ideal cause you can get
absolute voltages but for now, VCC/4 + 4x matches every other chip :)"

... and indeed doing it this way happens to give a much more steady
reading when using a VCC-referenced resistance, and so many of the simple
things you'd wire up are actually VCC-referenced anyway.
This commit is contained in:
jepler 2019-09-16 21:43:07 -05:00
parent c56186da8c
commit d39c85e3f5
1 changed files with 4 additions and 7 deletions

View File

@ -67,8 +67,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
const nrf_saadc_channel_config_t config = {
.resistor_p = NRF_SAADC_RESISTOR_DISABLED,
.resistor_n = NRF_SAADC_RESISTOR_DISABLED,
.gain = NRF_SAADC_GAIN1_6,
.reference = NRF_SAADC_REFERENCE_INTERNAL,
.gain = NRF_SAADC_GAIN1_4,
.reference = NRF_SAADC_REFERENCE_VDD4,
.acq_time = NRF_SAADC_ACQTIME_3US,
.mode = NRF_SAADC_MODE_SINGLE_ENDED,
.burst = NRF_SAADC_BURST_DISABLED,
@ -108,9 +108,6 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
}
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
// With internal reference, single ended input (grounded negative
// input), and a gain of 1/6 the input range will be:
// Input range = (0.6 V)/(1/6) = 3.6 V
// The AIN0-AIN7 inputs cannot exceed VDD, or be lower than VSS. (36.8)
return 3.6f;
// The nominal VCC voltage
return 3.3f;
}