Code: Select all
void Sensor_uncage(){
isCaged = false;
ESP_ERROR_CHECK (adc_continuous_start (adcHandle));
// adjust the ADC2 arbiter, as the driver resets it every time
adc_arbiter_t adc2ArbiterConfig = {
.mode = ADC_ARB_MODE_FIX,
.rtc_pri = 0,
.dig_pri = 2,
.pwdet_pri = 1,
};
adc_hal_arbiter_config (&adc2ArbiterConfig);
// ...
Interestingly, the ADC sampling frequency will be differently incorrect if you enable NVS for the initial startup process:
Code: Select all
void app_main (void) {
//Initialize NVS
esp_err_t flashInitResult = nvs_flash_init();
if (flashInitResult == ESP_ERR_NVS_NO_FREE_PAGES || flashInitResult == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK (nvs_flash_erase());
flashInitResult = nvs_flash_init();
}
ESP_ERROR_CHECK (flashInitResult);
Wifi_init();
ESP_ERROR_CHECK (nvs_flash_deinit());
Sensor_init();
Sensor_uncage();
// ...
Code: Select all
esp_wifi_init_internal
I'm obviously quite concerned about what might happen in the internal portions of the wifi stack if I find the misconfiguration and align things to what the DIG ADC driver wants. I'm especially concerned that I might produce something that works on my bench but exhibits strange long-term bugs in the field.
And yes, I am increasingly leaning towards using an external ADC with an SPI / I2C / I2S interface, as this would free up ADC1 for battery level measurements. The reason I'm trying to avoid this is that I need to change output pins as soon as possible after every pair of simultaneous ADC measurements, which is very easy to do with the DIG ADC driver but seems like it's probably a lot harder to do with an external device involved. Although it would be wasteful and silly I find myself tempted to just put two ESP32 modules on the board - but then I'll still be frustrated that I can't dedicate a radio each to Wifi and BLE and still do my sampling!