User manual
Installation and Operation
© 2007 Microchip Technology Inc. DS22027A-page 11
2.4 FUNCTIONAL DESCRIPTION
2.4.1 The MCP9800 Temperature Data Logger Demo Board 2
This demo board was originally developed for the use in a class to teach people the
basics of the I
2
C™ protocol. The code is formatted in such a manner that it is easy to
read and modify should one need to. Table 1-1 and Table 1-2 show some of the basic
subroutines and constant definitions used in the code. The TIMEOUTVAL variable may
be modified to put longer delays between measurements. Any value between 1
(default) and 255 may be used to vary the sample rate. The higher the number, the
slower the sample rate. The TIMEOUTVAL variable is approximately the number of sec-
onds delay between measurements.
2.5 I
2
C™ SUBROUTINES
The following subroutines provide low-level I
2
C support:
The following constants have been defined for communicating with the 24LC16B and
MCP9800:
Subroutine Descriptions
TABLE 1-1: I
2
C™ SUBROUTINES
Subroutine Description
BSTART
Generate an I
2
C™ bus Start condition.
BSTOP
Generate an I
2
C™ bus Stop condition.
SEND_ACK
Generate an I
2
C™ bus Acknowledge condition.
SEND_NACK
Generate an I
2
C™ bus Not Acknowledge condition.
BYTEOUT
Output an entire byte to the I
2
C™ bus.
BYTEIN
Input an entire byte from the I
2
C™ bus.
TABLE 1-2: CONSTANT DEFINITIONS
Constant Value Description
MEM_WRITE b’10100000’
Control byte for EEPROM write operation
MEM_READ b’10100001’
Control byte for EEPROM read operation
TEMP_WRITE b’10010000’
Control byte for temp. sensor write operation
TEMP_READ b’10010001’
Control byte for temp. sensor read operation
TEMP_REG 0x00
Temperature register address for temp. sensor
CONFIG_REG 0x01
Configuration register address for temp. sensor
SHUTDOWN b’00000001’
Configuration value for Shutdown mode
ONESHOT b’10000001’
Configuration value for One-Shot mode
BSTART
Description: Generate an I
2
C bus Start condition.
Arguments: None.
Output: None.
Return Value: 0
Code Example:
call BSTART ; Generate Start
BSTOP
Description: Generate an I
2
C bus Stop condition.
Arguments: None.