Hardware Reference
In-Depth Information
TC72
HCS12 MCU
V DD
V DD
CE
PM1
0.1
μ
F
SCK0
SCK
SDO
MISO0
SDI
MOSI0
GND
Figure 10.16 Circuit connection between the TC72 and the HCS12
void openspi0(void)
{
SPI0BR 5 0x10;
// set baud rate to 6 MHz
SPI0CR1 5 0x50;
SPI0CR2 5 0x02;
WOMS 5 0x00;
// enable Port S pull-up
}
void int2alpha(unsigned int xx, char *ptr) {
int quo;
*(ptr 1 2) 5 xx % 10 1 0x30;
quo 5 xx/10;
if(quo ! 5 0){
*(ptr 1 1) 5 quo % 10 1 0x30;
quo 5 quo/10;
// tens digit
}
if(quo ! 5 0)
*ptr 5 quo 1 0x30;
}
void read_temp (char *ptr)
{
char hi_byte, lo_byte, temp, *bptr;
unsigned int result;
*ptr 5 0x20;
// initialize the temperature buffer to 0.0
*(ptr 1 1) 5 0x20;
// and place two space characters before
*(ptr 1 2) 5 0x30;
// 0.0
*(ptr 1 3) 5 '.';
//
*(ptr 1 4) 5 0x30;
//
bptr 5 ptr;
PTM
| 5 BIT1;
// enable TC72 data transfer
putcspi0 (0x80);
// send out TC72 control register write address
putcspi0 (0x11);
// perform one-shot conversion
PTM
& 5 , BIT1;
// disable TC72 data transfer
delayby100ms(2);
// wait until temperature conversion is complete
 
Search WWH ::




Custom Search