Page 325 - ARM Based Microcontroller Projects Using MBED
P. 325
11.3 PROJECT 1—TMP102 TEMPERATURE SENSOR 311
00 Select the Temperature Register (read only)
01 Select the Configuration Register
10 Select the T LOW Register
11 Select the T HIGH Register
The Configuration Register is a 16-bit register and after power up or reset it is necessary to
configure this register. The register is configured by sending two consecutive bytes to it. The
following options can be configured (see the TMP102 data sheet for details: http://www.ti.
com/lit/ds/symlink/tmp102.pdf):
• shutdown mode
• thermostat mode
• polarity
• fault queue
• conversion resolution
• one-shot mode
• extended conversion mode
• alert bit
• conversion rate
In this example we will configure this register with the normal operating values by sending
0x60 followed by 0xA0. These are also the default register values after power up or reset. 0x60
sets the conversion resolution to 12 bits, continuous conversion mode. 0xA0 sets nonextended
mode of operation and 4Hz conversion rate.
The Temperature Register returns the temperature in two bytes as shown in Fig. 11.8,
where 4 bits of the lower byte are cleared to 0.
The temperature can be extracted from these two bytes by the following steps:
For positive temperatures:
• Shift the HIGH byte by 4 bits to the left into a 16-bit word called say, M.
• Shift the LOW byte by 4 bits to the right into a byte called say, L.
• Add M and L to find the 16-bit result.
• Multiply the result with 0.0625 (resolution) to find the temperature.
D7 D6 D5 D4 D3 D2 D1 D0
T11 T10 T9 T8 T7 T6 T5 T4
(T12) (T11) (T10) (T9) (T8) (T7) (T6) (T5)
D7 D6 D5 D4 D3 D2 D1 D0
T3 T2 T1 T0 0 0 0 0
(T4) (T3) (T2) (T1) (T0) (0) (0) (1)
FIG. 11.8 The Temperature Register.