This example code demonstrates how to read the internal temperature sensor of the NuMicro
M2L31 series microcontroller. Upon system startup, the factory-calibrated two-point data for
25°C and 125°C is retrieved from the RMC memory. Timer0 then triggers a measurement once
every second. During measurement, EADC Channel 28 measures the band-gap voltage to
calculate the actual AVDD voltage, while EADC Channel 29 measures the temperature sensor
voltage. After filtering out noise using a median filter, both values are converted into Celsius
using a two-point linear interpolation formula. Finally, the data is packed into a custom UART
packet and transmitted to the PC-side UI at 115200 bps, allowing users to view the real-time
temperature curve.
You can download the sample code at EC_M2L31_Internal_Temperature_Sensor_V1.00.
| 欢迎光临 牛卧堂MCU技术交流 (https://www.nuvoton-mcu.com/) | Powered by Discuz! X3.2 |