Skip to content

Commit 28e832c

Browse files
ginkgmespressif-bot
authored andcommitted
fix(adc2): fix cct and xpd configurations to improve precision of ADCs
1 parent 9ea3856 commit 28e832c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

components/driver/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#menu "Driver configurations"
2+
3+
menu "ADC configuration"
4+
5+
config ADC_FORCE_XPD_FSM
6+
bool "Use the FSM to control ADC power"
7+
default n
8+
help
9+
ADC power can be controlled by the FSM instead of software. This allows the ADC to
10+
be shut off when it is not working leading to lower power consumption. However
11+
using the FSM control ADC power will increase the noise of ADC.
12+
13+
endmenu # ADC Configuration
14+
15+
#endmenu # Driver configurations
16+

components/driver/rtc_module.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,18 @@ void adc_power_always_on()
10461046
void adc_power_on()
10471047
{
10481048
portENTER_CRITICAL(&rtc_spinlock);
1049+
//The power FSM controlled mode saves more power, while the ADC noise may get increased.
1050+
#ifndef CONFIG_ADC_FORCE_XPD_FSM
1051+
//Set the power always on to increase precision.
1052+
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
1053+
#else
1054+
//Use the FSM to turn off the power while not used to save power.
10491055
if (SENS.sar_meas_wait2.force_xpd_sar & SENS_FORCE_XPD_SAR_SW_M) {
10501056
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
10511057
} else {
10521058
SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_FSM;
10531059
}
1060+
#endif
10541061
portEXIT_CRITICAL(&rtc_spinlock);
10551062
}
10561063

@@ -1466,6 +1473,8 @@ static inline void adc2_config_width(adc_bits_width_t width_bit)
14661473
portENTER_CRITICAL(&rtc_spinlock);
14671474
//sar_start_force shared with ADC1
14681475
SENS.sar_start_force.sar2_bit_width = width_bit;
1476+
//cct set to the same value with PHY
1477+
SENS.sar_start_force.sar2_pwdet_cct = 4;
14691478
portEXIT_CRITICAL(&rtc_spinlock);
14701479

14711480
//Invert the adc value,the Output value is invert

0 commit comments

Comments
 (0)