SLAAE85 February   2023 MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3106 , MSPM0G3107 , MSPM0G3505 , MSPM0G3506 , MSPM0G3507 , MSPM0L1105 , MSPM0L1106 , MSPM0L1303 , MSPM0L1304 , MSPM0L1305 , MSPM0L1305-Q1 , MSPM0L1306 , MSPM0L1306-Q1


  1.   1
  2.   Revision History

Design description

This subsystem uses a resistor in series with a positive temperature coefficient (PTC) thermistor (TMP61) to form a voltage divider, which has the effect of producing an output voltage that is linear over temperature. This external circuit is read by setting up the MSPM0 internal op-amp in a buffer configuration and sampling with the ADC. If an increase of temperature is measured, an RGB LED turns red; if temperature decreases, the LED turns blue; and if no significant change in temperature, the LED remains green. This document does not go into details of calculating a temperature value from the ADC readings as such calculations are dependent on the thermistor chosen. Download the code example here.

#GUID-B9A1D2C5-5FE2-4878-A116-8E8287DD5251 shows the functional diagram of this subsystem.

Figure 1-1 Subsystem Functional Block Diagram

Required peripherals

This application requires an integrated OPA, ADC, Timer, and I/O pins.

Table 1-1
Sub-block functionality Peripheral Used Notes

Buffer amplifier

(1x) OPA

Called Thermistor_OPA_INST in code
Analog signal capture (1x) ADC12 Called ADC_INST in code
Timer for ADC sampling (1x) TIMERx Called Thermistor_TIMER_ADC in code
RGB LED Control (3x) I/O Pins Called RGB_RED_PIN, RGB_BLUE_PIN, and RGB_GREEN_PIN in code

Compatible devices

Based on the requirements in Table 1-1, this example is compatible with the devices in Table 1-2. The corresponding EVM may be used for prototyping.

Table 1-2
Compatible Devices EVM
MSPM0L13xx LP-MSPM0L1306
MSPM0G35xx, MSPM0G15xx LP-MSPM0G3507

Design Steps

  1. Determine Rbias. For the TMP61 thermistor used in this design, it is recommended for Rbias to be 10 kΩ. Other configurations are available. See the TMP61 data sheet for details.
    1. Other thermistors can have different Rbias recommendations or equations available to you for calculating Rbias. See the documentation for your chosen thermistor for details.
  2. Setup OPA in SysConfig for buffer configuration with external input.
  3. Setup ADC in SysConfig sample OPA output with chosen ADCMEMx.
  4. Set ADC sample time in SysConfig to a minimum of tSample_PGA as given in the device data sheet.
  5. Determine the temperature algorithm to use to convert ADC readings to temperature readings. This example uses raw ADC readings to calculate changes in temperature.

Design considerations

  1. Temperature calculation: Different thermistors will have various equations or lookup tables available in order to calculate temperature from the ADC readings and external circuit. Check your thermistor collateral for these resources that can be integrated into this design.
    1. Lookup tables take less compute time, but may not be valid for every situation and can possibly take up a large portion of memory.
    2. Equations take more compute time, but are more flexible to external variables. The complexity of the equations will depend on the accuracy or temperature range requirements.
  2. OPA supply will be VCC of the MSPM0.
  3. OPA GBW setting: A lower GBW setting for the OPA consumes less current, but responds slower; conversely, a higher GBW consumes more current, but has a larger slew rate and faster enable and settling times. See the device-specific data sheet for specification differences between the modes.
  4. ADC Reference selection: MSPM0 devices can provide a reference voltage to the ADC from an internal reference generator (VREF), external source, or MCU VCC. Check the MSPM0 device data sheet for options available for the chosen device. For the configuration of this design, it is recommended to have the ADC reference to be equal to the bias voltage (VCC) of the external thermistor circuit.
  5. ADC sampling: This example periodically samples the external circuit using a timer trigger. To adjust how often the circuit is sampled, adjust the timer parameters.
  6. ADC results: The code example only stores the most current result captured in the global variable gThermistorADCResult . Full applications may want to store several readings in an array before performing actions on the data.
  7. Race conditions on gCheckThermistor: This application clears gCheckThermistor as soon as possible. If the application waits too long to clear gCheckThermistor, the application can inadvertently miss new data.

Software flowchart

#GUID-F5C62073-5B1C-4C7B-9204-53B5842767E4 shows the code flow diagram for this example and explains how the ADC samples the OPA output and the decision tree for LED illumination.

Figure 1-2 Application Software Flowchart

Device configuration

This application makes use of TI System Configuration Tool (SysConfig) graphical interface to generate the configuration code of the device peripherals. Using a graphical interface to configure the device peripherals streamlines the application prototyping process.

The code for what is described in #GUID-F5C62073-5B1C-4C7B-9204-53B5842767E4 can be found in the beginning of main() in the Thermistor_Example.c file.

Application code

This application does not compute temperature directly, but looks for a change in temperature. The following code snippet includes a value CHANGEFACTOR which is used to determine a minimal amount of ADC value change before recognizing a temperature change.

volatileuint16_tgThermistorADCResult = 0;
volatileboolgCheckThermistor = false;

The following code snippet shows where to add the temperature calculation method for the thermistor to compute actual temperature values. The current code takes an initial reading (gInitial_reading) at startup and compares the current reading (gCelcius_reading) with the CHANGEFACTOR adjustment to see if temperature has increased, decreased, or not changed enough. The RGB LED is then turned red (increase), blue (decrease), or green (no change) respective to the comparison result.

  while (1) {
        while (gCheckThermistor == false) {
        //Insert Thermistor Algorithm
               gCelcius_reading = gThermistorADCResult;
               if (first_reading) {
                   gInitial_reading = gCelcius_reading;
                   first_reading   = false;
                * Change in LEDs is based on current sample compared to previous sample
                * If the new sample is warmer than CHANGEFACTOR from initial temp, turn LED red
                * If the new sample is colder than CHANGEFACTOR  from initial temp, turn LED blue
                * Else, keep LED green
                * Variable gAlivecheck is utilized for debug window to confirm code is executing.
                * It is not needed in final applications.
               if(gAlivecheck >= 0xFFF0){gAlivecheck =0;}
               if (gCelcius_reading - CHANGEFACTOR > gInitial_reading) {
                       RGB_PORT, (RGB_GREEN_PIN | RGB_BLUE_PIN));
                   DL_GPIO_setPins(RGB_PORT, RGB_RED_PIN);
               } else if (gCelcius_reading < gInitial_reading - CHANGEFACTOR) {
                       RGB_PORT, (RGB_RED_PIN | RGB_BLUE_PIN));
                   DL_GPIO_setPins(RGB_PORT, RGB_BLUE_PIN);
               } else {
                       RGB_PORT, (RGB_RED_PIN | RGB_BLUE_PIN));
                   DL_GPIO_setPins(RGB_PORT, RGB_GREEN_PIN);
               gCheckThermistor = false;