-
Notifications
You must be signed in to change notification settings - Fork 346
Feature esp32s2 adccal #3360
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
base: main
Are you sure you want to change the base?
Feature esp32s2 adccal #3360
Conversation
|
A few upfront "don't forget me"s:
|
|
Yes, I will remove and squash all of this eventually, but thanks for pointing them out. |
The esp32s2 somewhat uniquely has this weird adc_efuse_raw_map. Would it be fine to keep the table, but replace the const TAG_ efuse field and MapInfo::block/begin_bit/length duplication with a reference to the efuse/fields.rs? There's still the issue that idf's signed_bit_to_int function needs access to the private EfuseField::bit_len. |
|
This probably needs to be rebased on top of #3440 once its merged |
3cda292 to
91245ce
Compare
|
I have put more time into figuring this out and have used a different board. I am now using the V2 version of the efuse where a line calibration is embedded, instead of having to do a manual calibration (which I will now abandon). In short: I am stuck. |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packagescommand to ensure that all changed code is formatted correctly.CHANGELOG.mdin the proper section.Extra:
Pull Request Details 📖
I'm working on implementing ADC calibration for the ESP32-S2. I've made some progress, specifically reading calibration values from eFuse. I followed the code path in IDF’s examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c as a guide.
Still running into a few issues:
init_code:
The V1 eFuse lacks an init_code, so manual calibration is required, but I haven’t gotten it to work yet.
set_init_code didn’t do anything until @JurajSadel’s recent regi2c commits for the S2.
Right now, the manual calibration logic lives in
AdcConfig::enable_pin_with_cal(). But this runs before the ADC peripheral is initialized. This means it will hang onwhile !ADCI::is_done() {}and just not work properly in general. Probably better to add acalibrate()method to AdcCalSource and call it fromAdc::new()in a loop over the pins.Manual calibration always reads 0 for me, even though post-calibration reads do register a signal. I tested this by copy-pasting the
Adc::newinit code into adc_calibrate to get past the init ordering issue. The idf's self-calibration init code is around 0x680.scheme_line_fitting from IDF:
This calculates slope and y-intercept from eFuse or a self-cal step. The y-intercept is often positive, which makes it unusable with AdcCalBasic, since that applies correction before the scaling in AdcCalLine.
Also, the example seems to use both init_code AND a full affine correction
Cleanup
Description
Implement adc calibration for the esp32s2.
#1203
#326
Testing
Some manual testing, not yet finished.
I get the same efuse line calibration values as idf.