mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'fix/adc_c6_get_high_result' into 'master'
fix(adc): fix ESP32C6 ADC get high result after enable Closes ESPCS-1045 See merge request espressif/esp-idf!42964
This commit is contained in:
@@ -115,9 +115,11 @@ static void adc_hal_onetime_start(adc_unit_t unit, uint32_t clk_src_freq_hz, uin
|
||||
}
|
||||
|
||||
HAL_EARLY_LOGD(TAG, "delay for `onetime_start` signal captured: %"PRIu32"", sample_delay_us);
|
||||
|
||||
adc_oneshot_ll_start(true);
|
||||
esp_rom_delay_us(sample_delay_us);
|
||||
adc_oneshot_ll_start(false);
|
||||
esp_rom_delay_us(sample_delay_us);
|
||||
adc_oneshot_ll_start(true);
|
||||
|
||||
#if ADC_LL_DELAY_CYCLE_AFTER_DONE_SIGNAL
|
||||
/**
|
||||
@@ -147,7 +149,6 @@ bool adc_oneshot_hal_convert(adc_oneshot_hal_ctx_t *hal, int *out_raw)
|
||||
}
|
||||
|
||||
adc_oneshot_ll_clear_event(event);
|
||||
adc_oneshot_ll_disable_all_unit();
|
||||
adc_oneshot_ll_enable(hal->unit);
|
||||
|
||||
adc_hal_onetime_start(hal->unit, hal->clk_src_freq_hz, &read_delay_us);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_rom_sys.h"
|
||||
|
||||
#include "soc/adc_periph.h"
|
||||
#include "soc/apb_saradc_struct.h"
|
||||
@@ -901,7 +902,11 @@ static inline void adc_oneshot_ll_output_invert(adc_unit_t adc_n, bool inv_en)
|
||||
static inline void adc_oneshot_ll_enable(adc_unit_t adc_n)
|
||||
{
|
||||
HAL_ASSERT(adc_n == ADC_UNIT_1);
|
||||
APB_SARADC.saradc_onetime_sample.saradc_saradc1_onetime_sample = 1;
|
||||
// For ESP32C6, it need to delay 50us after enable oneshot mode to ensure the ADC channel select is stable.
|
||||
if (APB_SARADC.saradc_onetime_sample.saradc_saradc1_onetime_sample == 0) {
|
||||
APB_SARADC.saradc_onetime_sample.saradc_saradc1_onetime_sample = 1;
|
||||
esp_rom_delay_us(50);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -909,8 +914,7 @@ static inline void adc_oneshot_ll_enable(adc_unit_t adc_n)
|
||||
*/
|
||||
static inline void adc_oneshot_ll_disable_all_unit(void)
|
||||
{
|
||||
APB_SARADC.saradc_onetime_sample.saradc_saradc1_onetime_sample = 0;
|
||||
APB_SARADC.saradc_onetime_sample.saradc_saradc2_onetime_sample = 0;
|
||||
// For ESP32C6, we keep saradc_saradc1_onetime_sample as 1 when oneshot mode.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user