Hardware Reference
In-Depth Information
temp2
5
(ATD0DR0 * 10) % 62;
/* remainder part */
temp1
25
40;
/* subtract the offset from the actual temperature */
if (temp1
,
0){
/* temperature is negative */
sign
5
1;
temp1
5
2
temp1;
/* find the magnitude of temperature */
if (temp2) { /* remainder not zero */
temp1
22
;
temp2
5
62
2
temp2;
}
}
fdigit
5
(temp2 * 10)/62;
/* compute the fractional digit */
frem
5
(temp2 * 10) % 62;
if (frem
.
31) {
fdigit
11
;
if (fdigit
55
10) {
/* round off the fractional digit */
fdigit
5
0;
temp1
11
;
}
}
if (sign) {
ptr
5
&buf[1];
/* point to the first space to hold ASCII string */
buf[0]
5
0x2D;
/* store minus sign as the first character */
}
else
ptr
5
&buf[0];
int2alpha(temp1,ptr);
/* convert the integer part to ASCII string */
ptr
5
&buf[0];
while(*ptr)
/* find the end of the integer string */
ptr
11
;
*ptr
11
5
'.';
*ptr
11
5
fdigit
1
0x30;
*ptr
11
5
223;
/* add a degree character */
*ptr
11
5
'C';
/* temperature in Celsius */
*ptr
5
0;
/* terminate the temperature string */
cmd2lcd(0xC0);
/* move cursor to 2nd row */
puts2lcd(blanks);
/* clear the 2nd row */
cmd2lcd(0xC5);
/* set cursor to column 5 row 2 */
puts2lcd(&buf[0]);
/* output the temperature */
delayby100ms(2);
/* wait for 0.2 seconds */
}
}
void openAD0(void)
{
ATD0CTL2
5
0xE0;
/* enable AD0, fast ATD flag clear, power-down on wait */
ATD0CTL3
5
0x0A;
/* perform one ATD conversion */
ATD0CTL4
5
0x25;
/* prescaler set to 12, select four cycles sample time */
delayby10us(2);
}
▲
Search WWH ::
Custom Search