User Tools

Site Tools


mmbasic:temperature_measurement_reading_the_internal_sensor_on_pic32mx170

Temperature measurement reading the internal sensor on PIC32MX170

Novel CFunction to get the reading from the on-die temperature sensor. This Function is only suitable for the 28 and 44 pin MX170 CPUs.

originally published here: http://www.thebackshed.com/forum/forum_posts.asp?TID=7822

Credit:matherp

do  
print readinternaltemp()  
pause 1000  
loop  



CFunction readinternaltemp 
     00000000 
     27bdffc8 afbf0034 afbe0030 afb7002c afb60028 afb50024 afb40020 afb3001c  
     afb20018 afb10014 afb00010 3c030200 34638001 3c02bf81 ac43a200 3c031000  
     3c02bf88 ac431064 3c02bf88 ac401068 34038000 3c02bf81 ac439004 24100001  
     00008821 3c12bf81 3c13000d 3c14bf88 3c15bf88 3c16bf81 3c17ffff 10000002  
     3c1ebf81 26100001 ae539040 ae806118 aea06108 aed79050 34028f00 afc29020  
     24020003 3c03bf81 ac629010 240200e4 3c03bf81 ac629000 34028000 3c03bf81  
     ac629008 3c04bf88 3c031000 8c821030 00431024 1040fffd 3c02bf81 8c429070  
     02228821 24020001 12020028 3c031000 3c02bf88 ac431034 3c029d00 8c420004  
     0040f809 240403e8 2a020009 1440ffde 26100001 3c031000 3c02bf88 ac431064  
     3c02bf88 ac401068 34038000 3c02bf81 ac439004 3c02bf81 ac40a200 24020588  
     00518823 26220007 2a230000 0223100a 000210c3 2442001c 00021fc3 8fbf0034  
     8fbe0030 8fb7002c 8fb60028 8fb50024 8fb40020 8fb3001c 8fb20018 8fb10014  
     8fb00010 03e00008 27bd0038 3c02bf88 ac431034 3c029d00 8c420004 0040f809  
     240403e8 1000ffb7 00008821  
End CFunction   'MIPS32 M4K

I recommend you don't use this as an absolute measurement - the junction seems to wander about a bit and benefit from being averaged over 20 or so readings.

Even so, tests show a large variation in the measured temperature which generally correlates to the amount of processing being done. Because the sensor is fabricated directly onto the chip, it is affected by the temperature of the die - which in turn is heated by the workload - to be expected really. Reduce the workload/speed and you reduce the “artificial” heating of the sensor. One specific test shows that in an ambient temperature of 21C with readings averaged over 50 samples, at 5MHz the temperature was ~25C but at 48MHz it was ~30.5C - a five degree variance where the only change was the speed of the CPU.

In conclusion, this is a useful function so long as the affecting aspects are remembered. If you want a “proper” temperature measurement, use a proper temperature sensor. If you use this as an enclosure temperature indicator, i.e for an alarm at 60C say, then it will probably be a good addition

mmbasic/temperature_measurement_reading_the_internal_sensor_on_pic32mx170.txt · Last modified: 2024/01/19 09:30 by 127.0.0.1