Datasheet

F1 Evaluation Platform User’s Guide
DS41401B-page 28 2010 Microchip Technology Inc.
5.9.1 MCP9800 Function Interface
5.9.1.1 mcp9800_init
This function configures the MCP9800 for 12-bit temperature, Continuous Conversion
mode. In this mode, the temperature is always ready to be read from the I
2
C interface.
FIGURE 5-15:
5.9.1.2 mcp9800_get_temp
This function reads the current temperature and scales the result to degrees C * 10.
(24.3C is returned 243)
FIGURE 5-16:
System_init()
{
i2c_init();
mcp9800_init();
}
Thermostat()
{
int temperature;
temperature = mcp9800_get_temp();
if(temperature > 260)
{
turn_on_air_conditioner();
}
}