-
Notifications
You must be signed in to change notification settings - Fork 143
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
[stm32] Fix address of F0 temperature calibration values #526
[stm32] Fix address of F0 temperature calibration values #526
Conversation
I just figured out the modm adc temperature sensor code does not work on F0 "Value Line Devices" (030, 070) which don't have a valid value for |
I remember that the addresses of these values were only written in the datasheet, and are different between devices. Perhaps there is a list of them in CubeMX or the CubeHAL, lemme check. |
The values are hardcoded in the CubeHAL and identical for all chips of the same family. |
ac1d2b0
to
c45623f
Compare
@salkinium @rleh Does anyone of you have an F030 or F070 board lying around to test the change? It compiles for F030C6 but I have nothing to test it on. The F030 code I added comes more or less directly from the reference manual Appendix A.7.16: |
STM32F072 are different. ST calibrates all STM32 ADC temperature sensors at two temperature points except "STM32F0 Value line devices", also known as F030 and F070. They use a different code path to calculate the temperature. If one had a suitable board, I would have added a BSP and an example. In modm we only have one board with a matching controller, the stm32f030f4p6 demo board. This one basically has nothing on it except for a power supply and an orange led. I could add a quite meaningless example to get at least some CI coverage for compilation. |
I have the |
Something isn't working right. #include <modm/board.hpp>
using namespace Board;
int main()
{
Board::initialize();
Adc::initialize<Board::SystemClock, Adc::ClockMode::Synchronous, 12_MHz>();
const uint16_t Vref = Adc::readInternalVoltageReference();
while (true)
{
int16_t Temp = Adc::readTemperature(Vref);
LedOrange::set(Temp > 685);
modm::delay(1s);
}
return 0;
} Stepping though this example I get 686°C.
|
c45623f
to
3ecad35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in hardware, works.
Thanks for testing! |
The addresses for the temperature sensor calibration values are wrong in modm. ST manual:
When first trying to use the ADC temperature sensor on a custom board with an F042K6 I ended up in the hardfault handler. I am wondering how the nucleo f042k6 adc example could have ever worked. This change is tested on real hardware.
I'll also fix the example which has these addresses hardcoded for demonstration purposes.