Hardware Reference
In-Depth Information
Operation Mode
One-Shot Bit
Shutdown Bit
Continuous temperature conversion
0
0
Shutdown
0
1
Continuous temperature conversion
1
0
One-shot
1
1
Table 10.5 Control register temperature conversion mode selection
port remains active. If the SHDN bit is 0, the TC72 will perform a temperature conversion ap-
proximately every 150 ms. In normal operation, a temperature conversion will be initialized by a
write operation to the control register to select either the continuous temperature conversion or
the one-shot operation mode. The temperature data will be available in the upper byte and lower
byte of the temperature register approximately 150 ms after the control register is written into.
The one-shot mode performs a single temperature measurement and returns to the power-
saving mode. After completion of the temperature conversion, the one-shot bit is reset to 0. The
user must set the one-shot bit to 1 to initiate another temperature conversion.
T EMPERATURE R EGISTER
The temperature register is a read-only register and contains a 10-bit two's complement
representation of the temperature measurement. Bit 0 through bit 5 are always read as 0. After
reset, the temperature register is reset to 0.
M ANUFACTURING ID R EGISTER
This register is read-only and is used to identify the temperature sensor as a Microchip
component.
Example 10.6
Describe the circuit connection between the HCS12 MCU and the TC72 for digital tem-
perature reading, and write a C function to read the temperature every 200 ms. Convert the
temperature value into a string so that it can be displayed on an appropriate output device.
A pointer to the buffer to hold the string will be passed to this function. The E-clock frequency
of the demo board is assumed to be 24 MHz.
Solution: A possible circuit connection is shown in Figure 10.16. A 0.1- to 1.0-
μ
F capacitor
should be added between the V DD and the GND pins to filter out power noise.
The C function ( read_temp() ) that starts a temperature measurement and converts the tem-
perature reading into a string is as follows:
#include “c:\cwHCS12\include\hcs12.h”
#include “c:\cwHCS12\include\spi0util.h”
#include “c:\cwHCS12\include\delay.h”
void openspi0(void);
void read_temp (char *ptr);
char buf[10];
void main (void)
{
DDRM | 5 BIT1;
// configure the PM1 pin for output
openspi0();
// configure SPI0 module
read_temp(&buf[0]);
}
 
Search WWH ::




Custom Search