无法将原始 ADC1 读数转换为电压

unable to convert raw ADC1 reading to voltage

我无法理解为什么 ESP-IDF 电压计算应用于转换来自 GPIO39 的原始读数会导致崩溃?

uint32_t电压=esp_adc_cal_raw_to_voltage(read_raw,adc_chars);

下面是简单的源码

 #include <stdio.h>
    #include <stdlib.h>
    #include "freertos/FreeRTOS.h"
    #include "freertos/task.h"
    #include "freertos/queue.h"
    #include "driver/gpio.h"
    #include "driver/adc.h"
    #include "driver/dac.h"
    #include "esp_system.h"
    #include "esp_adc_cal.h"
    #define BLINK_GPIO 2
    static const adc_atten_t atten = ADC_ATTEN_DB_11;
    static const adc_unit_t unit = ADC_UNIT_1;
    #define DEFAULT_VREF    1100
    static void Read_GPIO39() {
        int read_raw = 0;
        adc1_config_width(ADC_WIDTH_BIT_12);
        adc1_config_channel_atten(ADC1_CHANNEL_3, ADC_ATTEN_DB_11);
        read_raw=adc1_get_raw(ADC1_CHANNEL_3);
       adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));


esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF,adc_chars);
       **//uint32_t voltage = esp_adc_cal_raw_to_voltage(read_raw, adc_chars);**
        printf("Intensity : %d\n", read_raw);

        //printf("Voltage: %d\n", voltage);
        gpio_pad_select_gpio(BLINK_GPIO);
        gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
        gpio_set_level(BLINK_GPIO, 1);
    }


    void app_main() {
        ESP_ERROR_CHECK(nvs_flash_init());
        // initialise_wifi();
        while (1) {
            Read_GPIO39();

            vTaskDelay(3000 / portTICK_PERIOD_MS);
            gpio_set_level(BLINK_GPIO, 0);
        }


    }

根据下面的两个陈述,电压读数可能与实际电压读数有 +/-7% 的偏差,原始读数最大值 =4095 或 2^12 位 ~= 3.3v。范围似乎在其他人之前测试和记录的区域内。

static const adc_atten_t atten = ADC_ATTEN_DB_11;
    static const adc_unit_t unit = ADC_UNIT_1;
    #define DEFAULT_VREF    1100
 adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));

 esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF,adc_chars);