SLAAE85 February 2023 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3106 , MSPM0G3107 , MSPM0G3505 , MSPM0G3506 , MSPM0G3507 , MSPM0L1105 , MSPM0L1106 , MSPM0L1303 , MSPM0L1304 , MSPM0L1304-Q1 , MSPM0L1305 , MSPM0L1305-Q1 , MSPM0L1306 , MSPM0L1306-Q1 , MSPM0L1343 , MSPM0L1344 , MSPM0L1345 , MSPM0L1346
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.
Figure 1-1 shows the functional diagram of this subsystem.
This application requires an integrated OPA, ADC, Timer, and I/O pins.
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 |
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.
Compatible Devices | EVM |
---|---|
MSPM0L13xx | LP-MSPM0L1306 |
MSPM0G35xx, MSPM0G15xx | LP-MSPM0G3507 |
Figure 1-2 shows the code flow diagram for this example and explains how the ADC samples the OPA output and the decision tree for LED illumination.
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 Figure 1-2 can be found in the beginning of main() in the Thermistor_Example.c file.
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.
#include"ti_msp_dl_config.h"
#include<math.h>
#define CHANGEFACTOR 10
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) {
__WFE();
}
//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.
*
*/
gAlivecheck++;
if(gAlivecheck >= 0xFFF0){gAlivecheck =0;}
if (gCelcius_reading - CHANGEFACTOR > gInitial_reading) {
DL_GPIO_clearPins(
RGB_PORT, (RGB_GREEN_PIN | RGB_BLUE_PIN));
DL_GPIO_setPins(RGB_PORT, RGB_RED_PIN);
} else if (gCelcius_reading < gInitial_reading - CHANGEFACTOR) {
DL_GPIO_clearPins(
RGB_PORT, (RGB_RED_PIN | RGB_BLUE_PIN));
DL_GPIO_setPins(RGB_PORT, RGB_BLUE_PIN);
} else {
DL_GPIO_clearPins(
RGB_PORT, (RGB_RED_PIN | RGB_BLUE_PIN));
DL_GPIO_setPins(RGB_PORT, RGB_GREEN_PIN);
}
gCheckThermistor = false;
__WFI();
}