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

Temperature calculation improvements #111

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

stabler
Copy link
Contributor

@stabler stabler commented Jan 3, 2024

Improves the temperature calculations to account for vdda, which is 3V when the temperature sensor is calibrated but may vary in the target application. Additionally, updates the ADC examples to use VDDA (in two cases, adc-one-shot-dma.rs uses a hardcoded value to minimize changes).

I implemented the calculation using both floating point and integer arithmetic. The integer version is less accurate, but the promised accuracy is quite low (datasheet quotes +/- 5C) so I think in most cases the integer version is more than sufficient.

Note that in the standard peripheral library (link) the CAL2 temperature used is 110 degrees C, which is inconsistent with the STM32G4 datasheet. I assume this is a mistake.

I don't have access to the equipment to test this accurately at this time, but I get plausible readings at room temperature and after the part has warmed.

@no111u3 no111u3 merged commit 4fb9450 into stm32-rs:main Jan 4, 2024
2 of 21 checks passed
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

Successfully merging this pull request may close these issues.

2 participants