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 calibration #487

Open
mrx23dot opened this issue Jan 3, 2025 · 2 comments
Open

ADC calibration #487

mrx23dot opened this issue Jan 3, 2025 · 2 comments

Comments

@mrx23dot
Copy link

mrx23dot commented Jan 3, 2025

I have a theory that ADC calibration value is not auto applied.

image

based on ch32v307 implementation
https://github.com/Ivansquark/ch32/blob/7529e796615f2c7dd53d1fc4d1ddf597556f1f2c/ch32v307/freertos_socket_server/C/src/adc.c#L35C5-L35C21

@cnlohr
Copy link
Owner

cnlohr commented Jan 3, 2025

I believe you may be correct. I don't think anyone's ever vetted it. Perhaps we should just remove the cal from the ch32v003fun demo? I don't know a good way to apply the cal. And, I haven't seen an issue with any ADC readings so far. What does it look like for them to be out of cal?

@mrx23dot
Copy link
Author

mrx23dot commented Jan 3, 2025

simplest would be into a separate example:

static u32 adcOffset;

adc_init():
adcOffset = RDATAR; /* offset >= 0 */

adc_read():
u32 val = RDATAR;
return (val <= adcOffset) ? 0 : (val - adcOffset);

some application might need calibration.

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