SPRZ455D december 2020 – june 2023 DRA829J , DRA829J-Q1 , DRA829V , DRA829V-Q1 , TDA4VM , TDA4VM-Q1
ADVANCE INFORMATION
VTM: Software Reads from On-Die Temperature Sensors Can Be Corrupted
The WKUP_VTM_TMPSENS_STAT_j[9-0] DATA_OUT registers can be read in software to determine the last sampled temperature of each of the ‘j’ number of on die temp sensors on the SoC. If a read happens on the same exact cycle that a temperature sample is updated then there is a chance that the read data can be corrupted due to incorrect resynchronization between clock domains.
Software should perform three reads from the WKUP_VTM_TMPSENS_STAT_j[9-0] DATA_OUT registers. Software should then compute the temperature to be used based on the average of the two samples that are closest to each other.
The software pseudo code is as follows:
#define abs(x) (((x)<0)?-(x):(x))
unsigned int get_best_value(unsigned int s0, unsigned int s1, unsigned int s2)
{
int d01 = abs(s0 - s1);
int d02 = abs(s0 - s2);
int d12 = abs(s1 - s2);
// if delta 01 is least, take 0 and 1
if ((d01 <= d02) && (d01 <=d12)) {
return (s0+s1)/2;
}
// if delta 02 is least, take 0 and 2
if ((d02 <= d01) && (d02 <=d12)) {
return (s0+s2)/2;
}
/* in all other cases, take 1 and 2 */
return (s1+s2)/2;
}
unsigned int get_temp()
{
unsigned int s0,s1,s2;
s0 = Read WKUP_VTM_TMPSENS_STAT_j[9-0] DATA_OUT;
s1 = Read WKUP_VTM_TMPSENS_STAT_j[9-0] DATA_OUT;
s2 = Read WKUP_VTM_TMPSENS_STAT_j[9-0] DATA_OUT;
return get_best_value(s0,s1,s2);
}