Clear Filters
Clear Filters

How can I read the value of the internal temperature sensor on the TI F2837x Launchpad?

7 views (last 30 days)
I would like to read the temperature value of the on-board Temperature Sensor on the TI F2837x Launchpad Development Kit. I have seen that it can be enabled on channel ADCIN13 of ADCA of the Development Kit. How can I go about doing this in Simulink?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 May 2024
Please see the attached models for this workflow in releases before MATLAB R2024a and for MATLAB R2024a onwards. The details below of how each model works are included below for MATLAB R2023a and for MATLAB R2024a (which uses some new features).
Requirement:
The Internal Temperature sensor on the F28379D Launchpad can only be read using "ADCIN13" channel via ADCA. The steps to read the internal temperature sensor are:
  1. Set 'ENABLE' bit to 1 under under 'TSNSCTL' register.
  2. Read the corresponding raw value from ADCIN13 on ADCA.
  3. Convert the raw value to physical temperature units.
MATLAB R2023a:
In MATLAB R2023a, the requirement can be achieved through 'Memory Copy' and 'ADC' blocks. Please refer to the attached model "Int_Temp_Sensor_Test_R2023a.slx".
The logic of the model is briefly explained below:
  1. To ensure the 'TSNSCTL' register is only written once, the 'Data Store Memory' block is used and its value i.e. 'Init' is checked via the 'If' block.
  2. The 'ENABLE' bit of the 'TSNSCTL' register is set to 1 in the 'Configure TSNSCTL Register' Subsystem.
  3. The 'TSNSCTL' register is read back to ensure the 'ENABLE' bit is set.  
  4. The raw value of temperature is read via ADC and converted to physical units under the 'Read ADC' Subsystem.
MATLAB R2024a:
MATLAB R2024a has some new features that you could use to help with this workflow. The requirement can be achieved using the 'Register ReadWrite' and 'ADC' blocks. Please note that the 'Register ReadWrite' block is only supported from MATLAB R2024a onwards.
Please refer to the attached model "Int_Temp_Sensor_Test_R2024a.slx".
The logic of the model is briefly explained below:
  1. The 'ENABLE' bit of the 'TSNSCTL' register is directly set and read via the 'Register ReadWrite' block under the 'Configure TSNSCTL Register' Subsystem.
  2. The raw value of temperature is read via ADC and converted to physical units under the 'Read ADC' Subsystem.
  3. Please note that since this model is for reference only, the 'TSNSCTL' register is being written every time. The logic can be updated to be the same as in the R2023a model.
Test Challenges/Suggestions:
Write protection for the 'TSNSCTL' register:
  1. From the reference manual, we can find that 'TSNSCTL' has write protection (Page 1576 of the TMS320F2837xD Technical Reference Manual).
  2. So, EALLOW must be called before writing to the register and EDIS must be called after the write operation is completed.
  3. In R2023a, this is accessed via custom code options under the 'Options' tab of the 'Memory Copy' block parameters.
  4. In R2024a, this is accessed via the 'Insert code before/after:' dropdown option under the 'Register ReadWrite' block parameters.
ADC Acquisition window:
  1. Initially, when the ADC acquisition window size was set to a smaller value (say 15), the ADC did not read proper values.
  2. This was a bug and the recommended fix was to increase the acquisition window size. Refer to the below E2E link:
    1. https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/933850/launchxl-f28379d-internal-temperature-sensor-bug
  3. Once the acquisition window was increased to 250 or 511, the ADC read proper values.
ADC Reference Voltage:
  1. Initially, when the reference voltage for the ADC was considered as 2.5V, the converted temperature value was incorrect.
  2. Later it was found that the reference voltage for the corresponding ADC is 3V and not 2.5V.
  3. So, the measured raw count would have to be scaled as suggested in the reference manual (Page 1628 of the TMS320F2837xD Technical Reference Manual)
  4. After scaling the input raw value accordingly, the correct physical temperature value was decoded.
  5. Refer to the below E2E link:
    1. https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/830719/launchxl-f28379d-adc-measuring-with-simulink-getting-wrong-values
Temperature Slope and Offset values:
The reference manual suggests to refer to 'GetTemperatureC()' function in 'F2837xD_TempSensorConv.c' for converting raw to physical temperature units (Page 1628 of the TMS320F2837xD Technical Reference Manual)
  1. 'F2837xD_TempSensorConv.c' path: "C:\ti\controlSUITE\device_support\F2837xD\v210\F2837xD_common\source\F2837xD_TempSensorConv.c"
    1. Please note that this path might change as per the TI installation folder selection.
  2. Under the 'GetTemperatureC()' function, the 'tempSensor_tempOffset' and 'tempSensor_tempSlope' values are used for converting to physical units.
  3. These values are either:
    1. Read from OTP memory for production devices or
    2. Assigned static values for pre-production devices.
  4. When the corresponding values were read from OTP and used to compute physical temperature units, it resulted in an incorrect value. The values read from OTP were:
    1. Variable: 'tempSensor_tempSlope', Memory Location: 0x7036E, Value: 0x28A9 (Decimal: 10409)
    2. Variable: 'tempSensor_tempOffset', Memory Location: 0x70372, Value: 0x28A9 (Decimal: 10409)
  5. When static values were used for computation, the correct physical temperature value was decoded. The values were:
    1. Variable: 'tempSensor_tempSlope', Value: 5196
    2. Variable: 'tempSensor_tempOffset', Value: 1788
After implementing all the above points, the correct temperature value was read from ADC.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!