Other Parts Discussed in Thread: C2000WARE
Hello,
| Please tell me about the temperature measurement method built into TMS320F28027. |
| The code is as follows: |
| #define getTempSlope() (*(int (*)(void))0x3D7E80)() |
| #define getTempOffset() (*(int (*)(void))0x3D7E83)() |
| int32 sensorSample,TempSensorOffset,TempSensorSlope,DegreesC; |
| // Configure the ADC to sample the temperature sensor |
| EALLOW; |
| AdcRegs.ADCCTL1.bit.TEMPCONV = 1; //Connect A5 - temp sensor |
| AdcRegs.ADCSOC0CTL.bit.CHSEL = 5; //Set SOC0 to sample A5 |
| AdcRegs.ADCSOC1CTL.bit.CHSEL = 5; //Set SOC1 to sample A5 |
| AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //Set SOC0 ACQPS to 7 ADCCLK |
| AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //Set SOC1 ACQPS to 7 ADCCLK |
| AdcRegs.INTSEL1N2.bit.INT1SEL = 1; //Connect ADCINT1 to EOC1 |
| AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enable ADCINT1 |
| EDIS; |
| // Sample the temperature sensor |
| AdcRegs.ADCSOCFRC1.all = 0x03; //Sample temp sensor |
| while(AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){} //Wait for ADCINT1 |
| AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 |
| sensorSample = AdcResult.ADCRESULT1; //Get temp sensor sample result |
| TempSensorOffset = getTempOffset(); |
| TempSensorSlope = getTempSlope(); |
| //Convert raw temperature sensor output to a temperature (i.e. degC) |
| DegreesC = (sensorSample - TempSensorOffset) * TempSensorSlope; |
When the above code was executed, the variable values were as follows:
sensorSample = 2415
TempSensorOffset = 1607
TempSensorSlope = 5480
But I don't know the conversion to Celsius.
Degree C = (2415-1607) * 5480 = 4427840
4427840/2 ^ 15 = 135.1 ℃?
The manual is 3.3V, but this time using 2.495V external REF.
Is the conversion method as follows?
sensorSample = 2415 * 2.495 / 3.3 = 1825
TempSensorOffset = 1607 * 2.495 / 3.3 = 1214
TempSensorSlope = 5480 * 2.495 / 3.3 = 4143
Degree C = (1825-1214) * 4143 = 2531373
2531373/2 ^ 15 = 77.2 ℃?
Both are very different from the ambient temperature of 20 ℃.
Is something wrong?
Best regard,