Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC readings on idf-5.0+ are offset by -30mV compared to IDF-4.4 (IDFGH-8212) #9705

Closed
3 tasks done
pavlohamov opened this issue Sep 2, 2022 · 2 comments
Closed
3 tasks done
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@pavlohamov
Copy link
Contributor

pavlohamov commented Sep 2, 2022

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

release5.0/master VS release4.4

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

No response

Development Kit.

esp32s2-saola

Power Supply used.

USB

What is the expected behavior?

128 mV are sourced to GPIO_3 (ADC1_CH2) ADC conversion vis calibration results in 128mV

What is the actual behavior?

128 mV are sourced to GPIO_3 (ADC1_CH2) ADC conversion vis calibration results in 98mV on idf5.0

Steps to reproduce.

  1. Source 128 mV to GPIO_3 (ADC1_CH2) (e.g,. voltage divider 10K POT)

  2. build and execute IDF-4.4 examples/peripherals/adc/single_read/single_read

  3. build and execute IDF-5.0+ (or master 91e8312) examples/peripherals/adc/single_read/single_read

  4. Observe that IDF 5.0 readings have -30 mV offset compared to idf4.4

  5. Step

  6. Step
    ...

Debug Logs.

IDF-4.4
I (261) cpu_start: Starting scheduler on PRO CPU.
I (267) ADC1_CH2: raw  data: 401
I (267) ADC1_CH2: cali data: 129 mV
I (2267) ADC1_CH2: raw  data: 404
I (2267) ADC1_CH2: cali data: 130 mV
I (4267) ADC1_CH2: raw  data: 397
I (4267) ADC1_CH2: cali data: 128 mV
I (6267) ADC1_CH2: raw  data: 404
I (6267) ADC1_CH2: cali data: 130 mV
I (8267) ADC1_CH2: raw  data: 401
I (8267) ADC1_CH2: cali data: 129 mV
I (10267) ADC1_CH2: raw  data: 400
I (10267) ADC1_CH2: cali data: 128 mV
I (12267) ADC1_CH2: raw  data: 400
I (12267) ADC1_CH2: cali data: 128 mV
I (14267) ADC1_CH2: raw  data: 393
I (14267) ADC1_CH2: cali data: 126 mV

IDF-5.0
I (264) cpu_start: Starting scheduler on PRO CPU.
I (269) EXAMPLE: calibration scheme version is Line Fitting
I (269) EXAMPLE: Calibration Success
I (279) EXAMPLE: calibration scheme version is Line Fitting
I (279) EXAMPLE: Calibration Success
I (289) EXAMPLE: ADC1 Channel[2] Raw Data: 329
I (289) EXAMPLE: ADC1 Channel[2] Cali Voltage: 106 mV
I (3299) EXAMPLE: ADC1 Channel[2] Raw Data: 328
I (3299) EXAMPLE: ADC1 Channel[2] Cali Voltage: 105 mV
I (6299) EXAMPLE: ADC1 Channel[2] Raw Data: 329
I (6299) EXAMPLE: ADC1 Channel[2] Cali Voltage: 106 mV
I (9299) EXAMPLE: ADC1 Channel[2] Raw Data: 324
I (9299) EXAMPLE: ADC1 Channel[2] Cali Voltage: 104 mV

More Information.

128 mV are sourced to GPIO_3 (ADC1_CH2) additional 100uF capacitor (aluminium) is soldered to GPIO (leads ~ 2cm)
ADC readings differs much for latest idf.

Also I find out that it depends on HW calibration data. it is reproduced only for devices that reports "With ADC calibration V2"
One of IC's has readings calibration table

=== Run "adc_info" command ===

Temperature Sensor Calibration = -4.5C

ADC1 readings stored in efuse BLOCK2:
    MODE0 D1 reading  (250mV):  -56
    MODE0 D2 reading  (600mV):  -44
    MODE1 D1 reading  (250mV):  -44
    MODE1 D2 reading  (800mV):  -36
    MODE2 D1 reading  (250mV):  -36
    MODE2 D2 reading  (1000mV): -24
    MODE3 D1 reading  (250mV):  -20
    MODE3 D2 reading  (2000mV): -8

ADC2 readings stored in efuse BLOCK2:
    MODE0 D1 reading  (250mV):  -60
    MODE0 D2 reading  (600mV):  -76
    MODE1 D1 reading  (250mV):  -44
    MODE1 D2 reading  (800mV):  -68
    MODE2 D1 reading  (250mV):  -36
    MODE2 D2 reading  (1000mV): -56
    MODE3 D1 reading  (250mV):  -20
    MODE3 D2 reading  (2000mV): -56

BLOCK_SYS_DATA  (BLOCK2          ) [2 ] read_regs: 85ecc91c d00c3800 c797e6ed b97a9050 898b9690 91938286 9aee8e8e 969aef96

other one just:

=== Run "adc_info" command ===

BLOCK2_VERSION = With ADC calibration V2

BLOCK_SYS_DATA  (BLOCK2          ) [2 ] read_regs: 3406fada 0ffedbfe 27579807 1b19ad7d 1448b0a1 861878a2 0a4c0c50 08061783

Device with ADC readings table provides proper readings (offset is couple of mV). This issue is crucial for our product, a lot of production devices are affected by this issue.

@pavlohamov pavlohamov added the Type: Bug bugs in IDF label Sep 2, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Sep 2, 2022
@github-actions github-actions bot changed the title ADC readings on idf-5.0+ are offset by -30mV compared to IDF-4.4 ADC readings on idf-5.0+ are offset by -30mV compared to IDF-4.4 (IDFGH-8212) Sep 2, 2022
@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Sep 5, 2022
@pavlohamov
Copy link
Contributor Author

pavlohamov commented Sep 5, 2022

@Icarus113 I've managed to find the root case by my own. Please take a look to PR #9715

setting log level to verbose for "efuse_rtc_table" gives:
V (264) efuse_rtc_table: V2 ADC2 ATTEN0 PARAM1 -> 29
V (269) efuse_rtc_table: V2 ADC2 ATTEN1 PARAM1 -> 30
V (275) efuse_rtc_table: V2 ADC2 ATTEN2 PARAM1 -> 31
V (281) efuse_rtc_table: V2 ADC2 ATTEN3 PARAM1 -> 32
V (286) efuse_rtc_table: V2 ADC3 ATTEN0 PARAM1 -> 29
V (292) efuse_rtc_table: V2 ADC3 ATTEN1 PARAM1 -> 30
V (298) efuse_rtc_table: V2 ADC3 ATTEN2 PARAM1 -> 31
V (303) efuse_rtc_table: V2 ADC3 ATTEN3 PARAM1 -> 32

obviously there is no ADC3

@Icarus113
Copy link
Collaborator

@pavlohamov Hi, thanks for this. I checked your PR, which is a correct fix. Will deal with your PR.

@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Selected for Development Issue is selected for development Resolution: NA Issue resolution is unavailable labels Sep 7, 2022
espressif-bot pushed a commit that referenced this issue Sep 22, 2022
adc2 eFuse offset is wrong on 4.4 to 5.0 transition

Closes #9705
Closes #9715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants