In this post code is given to read the temperature of an iMX6 running Windows. Does anyone know how the code should be changed to allow it to run on the iMX7?
Thanks in advance.
In this post code is given to read the temperature of an iMX6 running Windows. Does anyone know how the code should be changed to allow it to run on the iMX7?
Thanks in advance.
Could you please try this code →
#include <windows.h>
#include "MapMem.h"
#define OCOTP_ANA1 0x303504F0
#define TEMPMON_ADDR 0x30360000+0x0300
HANDLE MemMap;
int wmain(int argc, _TCHAR* argv[])
{
// Init map mem lib
HANDLE maphandle=Map_Init();
// we need to map the OCOTPANA1 fuse to read calibration values
volatile DWORD* ocotpana1;
ocotpana1=(DWORD*)Map_MapMemory(OCOTP_ANA1,sizeof(DWORD));
DWORD t0, t1;
t0 = (*ocotpana1>> 21);
if (t0 == 0)
t0 = 25;
t1 = (*ocotpana1 >> 9) & 0x1FF;
// map the TEMPMON registers (TEMPSENSE0 and TEMPSENSE1, both have separate registers to set,clear and toggle bits)
volatile DWORD *tempsense0,*tempsense1;
volatile DWORD *tempsense1set,*tempsense1clr,*tempsense1tog;
tempsense0=(DWORD*)Map_MapMemory(TEMPMON_ADDR,8*sizeof(DWORD));
tempsense1=tempsense0+4;
tempsense1set=tempsense1+1;
tempsense1clr=tempsense1+2;
tempsense1tog=tempsense1+3;
// measure
for (;;)
{
// power-on sensor
*tempsense1clr = 0x200;
Sleep(1);
// start
*tempsense1set=0x400;
Sleep(1);
// wait until measured value is valid
while (!(*tempsense1 & 0x800))
Sleep(1);
// calculate temperature in Celsius
DWORD tempcount= *tempsense1 & 0x1FF;
DWORD tmeas= tempcount - (t1 - t0);
// print it out
_tprintf(TEXT("Temperature: %d\r\n"),tmeas);
RETAILMSG(1,(TEXT("Temperature: %d\r\n"),tmeas));
*tempsense1clr = 0x200;
*tempsense1set = 0x400;
Sleep(1000);
}
return 0;
}
That’s great, thanks @luka.tx. It’s indicating that it’s running at a steady 44C in open air (I think I’m right in saying that with the current WEC2013 release that’s with no DVFS and only one core).
can we get the temperature of imx7 from within a node app?
i was using below command, anything similar?
cpu=$(
HI @tcapoli
According to the community rules, I would like to ask you a new Question with all the details about your application?
Thanks and best regards,
Jaski