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

ulp rtc clock calibration #86

Open
pidou46 opened this issue Sep 30, 2022 · 2 comments
Open

ulp rtc clock calibration #86

pidou46 opened this issue Sep 30, 2022 · 2 comments

Comments

@pidou46
Copy link
Contributor

pidou46 commented Sep 30, 2022

For time critical code, it could be needed to calibrate the ulp clock.

https://docs.espressif.com/projects/esp-idf/en/v4.2/esp32/api-guides/ulp_instruction_set.html#note-about-instruction-execution-time

Does it is possible to do it with micropython-esp32-ulp lib ?
If not is there a workaround ?

Thanks

@wnienhaus
Copy link
Collaborator

As far as I can see there is no way to call that rtc_clk_cal function from MicroPython.

Since our project is "only" an assembler for ULP assembly code, support for calling that calibration function would need to be added to MicroPython instead.

Looking into workarounds: I do see that the ulp_set_wakeup_period function in ESP-IDF does some calibration to (see here) determine how many cycles the ULP should sleep for between wakeups.

The result of that calculation (period_cycles) is then stored in a register (using the REG_SET_FIELD macro), which the ULP could read. So potentially that number could be useful to work backwards from?

Reading the code though, it appears to calibrate against the "slow clock" instead of the "fast clock" (that the documentation refers to). Then again the S2/S3 variant of the code does have a branch where it calibrates to RTC_CAL_8MD256, so you would need to test whether this entire approach could be viable/useful.

@pidou46
Copy link
Contributor Author

pidou46 commented Oct 10, 2022

Thanks for the workaround, I will test it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants