Hi everyone,
I'm trying to use the TEMPMON peripheral on my NXP microcontroller and could use some help. I'm not sure if TEMPMON is the internal sensor of the microcontroller. Can anyone explain how to set it up and read the temperature? Is there a sample code? I am writing in C and bare metal.
The nxp document link is now obsolete. I could not find the example codes.
https://www.nxp.com/docs/en/application-note/AN5215.pdf
I'm looking for:
A simple code example would be awesome!
Thanks!
The registers I found in the documentation file is :
#define TEMPMON_TEMPSENSE0_POWER_DOWN_MASK (0x1U)
#define TEMPMON_TEMPSENSE0_POWER_DOWN_SHIFT (0U)
#define TEMPMON_TEMPSENSE0_POWER_DOWN(x) (((uint32_t)(((uint32_t)(x)) << TEMPMON_TEMPSENSE0_POWER_DOWN_SHIFT)) & TEMPMON_TEMPSENSE0_POWER_DOWN_MASK)
#define TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK (0x2U)
#define TEMPMON_TEMPSENSE0_MEASURE_TEMP_SHIFT (1U)
#define TEMPMON_TEMPSENSE0_MEASURE_TEMP(x) (((uint32_t)(((uint32_t)(x)) << TEMPMON_TEMPSENSE0_MEASURE_TEMP_SHIFT)) & TEMPMON_TEMPSENSE0_MEASURE_TEMP_MASK)
#define TEMPMON_TEMPSENSE0_FINISHED_MASK (0x4U)
#define TEMPMON_TEMPSENSE0_FINISHED_SHIFT (2U)
#define TEMPMON_TEMPSENSE0_FINISHED(x) (((uint32_t)(((uint32_t)(x)) << TEMPMON_TEMPSENSE0_FINISHED_SHIFT)) & TEMPMON_TEMPSENSE0_FINISHED_MASK)
#define TEMPMON_TEMPSENSE0_TEMP_CNT_MASK (0xFFF00U)
#define TEMPMON_TEMPSENSE0_TEMP_CNT_SHIFT (8U)
#define TEMPMON_TEMPSENSE0_TEMP_CNT(x) (((uint32_t)(((uint32_t)(x)) << TEMPMON_TEMPSENSE0_TEMP_CNT_SHIFT)) & TEMPMON_TEMPSENSE0_TEMP_CNT_MASK)
#define TEMPMON_TEMPSENSE0_ALARM_VALUE_MASK (0xFFF00000U)
#define TEMPMON_TEMPSENSE0_ALARM_VALUE_SHIFT (20U)
#define TEMPMON_TEMPSENSE0_ALARM_VALUE(x) (((uint32_t)(((uint32_t)(x)) << TEMPMON_TEMPSENSE0_ALARM_VALUE_SHIFT)) & TEMPMON_TEMPSENSE0_ALARM_VALUE_MASK)
Hello,
Yes, you have to get the 3.14.28 BSP to get those examples, Linux BSP has a thermal driver that implements the TempMon equation along with the associated thermal trip points (drivers/thermal/imx_thermal.c). The software thermal driver uses the TempMon
module to monitor the on-die temperature and take appropriate actions such as throttling back the core
frequency when a temperature interrupt (thermal trip point) is set
Regards