]> granicus.if.org Git - esp-idf/commitdiff
fix(adc2): fix cct and xpd configurations to improve precision of ADCs
authormichael <xiaoxufeng@espressif.com>
Wed, 7 Mar 2018 07:04:43 +0000 (15:04 +0800)
committerbot <bot@espressif.com>
Mon, 26 Mar 2018 12:02:26 +0000 (12:02 +0000)
components/driver/Kconfig [new file with mode: 0644]
components/driver/rtc_module.c

diff --git a/components/driver/Kconfig b/components/driver/Kconfig
new file mode 100644 (file)
index 0000000..7ef1a7f
--- /dev/null
@@ -0,0 +1,16 @@
+#menu "Driver configurations"
+
+menu "ADC configuration"
+
+config ADC_FORCE_XPD_FSM
+    bool "Use the FSM to control ADC power"
+    default n
+    help
+        ADC power can be controlled by the FSM instead of software. This allows the ADC to 
+        be shut off when it is not working leading to lower power consumption. However 
+        using the FSM control ADC power will increase the noise of ADC.
+
+endmenu  # ADC Configuration
+
+#endmenu  # Driver configurations
+
index 0d3974c5cdb5fecdc225a7e5913714725a6c31ad..10833c92eecd116c62868ef93121314203c6ebc2 100644 (file)
@@ -1046,11 +1046,18 @@ void adc_power_always_on()
 void adc_power_on()
 {
     portENTER_CRITICAL(&rtc_spinlock);
+    //The power FSM controlled mode saves more power, while the ADC noise may get increased.
+#ifndef CONFIG_ADC_FORCE_XPD_FSM
+    //Set the power always on to increase precision.
+    SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
+#else    
+    //Use the FSM to turn off the power while not used to save power.
     if (SENS.sar_meas_wait2.force_xpd_sar & SENS_FORCE_XPD_SAR_SW_M) {
         SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_PU;
     } else {
         SENS.sar_meas_wait2.force_xpd_sar = SENS_FORCE_XPD_SAR_FSM;
     }
+#endif
     portEXIT_CRITICAL(&rtc_spinlock);
 }
 
@@ -1466,6 +1473,8 @@ static inline void adc2_config_width(adc_bits_width_t width_bit)
     portENTER_CRITICAL(&rtc_spinlock);
     //sar_start_force shared with ADC1
     SENS.sar_start_force.sar2_bit_width = width_bit;
+    //cct set to the same value with PHY
+    SENS.sar_start_force.sar2_pwdet_cct = 4;
     portEXIT_CRITICAL(&rtc_spinlock);
 
     //Invert the adc value,the Output value is invert