Skip to content

Commit

Permalink
fix(battery): change nRF52 ADC gain
Browse files Browse the repository at this point in the history
With ADC pin, maximum 3.6V input needs gain 1/6 to be less than the 0.6V
reference.

With VDDHDIV5, maximum 6V input corresponds to 1.2V so gain 1/2 will be less
than the 0.6V reference and be slightly more precise.
  • Loading branch information
xudongzheng authored and petejohanson committed Jul 30, 2023
1 parent cb9c573 commit e65a7e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/drivers/sensor/battery/battery_nrf_vddh.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int vddh_init(const struct device *dev) {

#ifdef CONFIG_ADC_NRFX_SAADC
drv_data->acc = (struct adc_channel_cfg){
.gain = ADC_GAIN_1_5,
.gain = ADC_GAIN_1_2,
.reference = ADC_REF_INTERNAL,
.acquisition_time = ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40),
.input_positive = SAADC_CH_PSELN_PSELN_VDDHDIV5,
Expand Down
2 changes: 1 addition & 1 deletion app/drivers/sensor/battery/battery_voltage_divider.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int bvd_init(const struct device *dev) {

#ifdef CONFIG_ADC_NRFX_SAADC
drv_data->acc = (struct adc_channel_cfg){
.gain = ADC_GAIN_1_5,
.gain = ADC_GAIN_1_6,
.reference = ADC_REF_INTERNAL,
.acquisition_time = ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40),
.input_positive = SAADC_CH_PSELP_PSELP_AnalogInput0 + drv_cfg->io_channel.channel,
Expand Down

0 comments on commit e65a7e3

Please sign in to comment.