EEE445 MICROPROCESSOR SYSTEMS PROJECT DOCUMENTATION
Project: Real time clock and digital temperature sensor using I2c bus and AT89s52
what is I2C bus and why use it?
Any I²C device can be attached to an I²C-bus and every device can talk with any master, passing information back and forth. There needs to be at least one master (e.g., microcontroller or DSP) on the bus but there can be more than one, with all masters having equal priority. Devices can be easily added to and removed from the I²C-bus. Each device has a unique 7-bit I²C address so that the master knows specifically whom they are communicating with. Typically the four most significant bits are fixed and assigned to specific categories of devices (e.g. 1010 is assigned to serial EEPROMs). The three less significant bits (e.g., A2, A1 and A0) are programmable through hardware address pins allowing up to eight different I²C address combinations and therefore allowing up to eight of that type of device to operate on the same I²C-bus.
Only 2 bus lines required: data (SDA) and clock (SCL)
Each device connected to the bus is software addressable by a unique address
2 modes: Master-Transmitter and as Master-Receiver
Created and developed by Philips
More than 20 years of existence
Has become a world-wide standard
Standard adopted by all the industry
ICs can be added to or removed from a system without affecting any other circuits on the bus.
Simplicity: 2 wire protocol
Robustness of the protocol
here is how to write to and read data from an i2c bus;
LM75 I2C TEMP SENSOR:The LM75 is a temperature sensor, Delta-Sigma analog-to digital converter, and digital over-temperature detector with I2C® interface. The host can query the LM75 at any time to read temperature.
I2c slave address of lm75;
TEMPERATURE DATA FORMAT
Temperature data can be read from the Temperature, TOS Set Point, and THYST Set Point registers; and written to the TOS Set Point, and THYST Set Point registers. Temperature
data is represented by a 9-bit, two’s complement word with an LSB (Least Significant Bit) equal to 0.5°C:
here is i2c bus timing diagram for reading two bytes from lm75;
DS1307 I2C RTC:
DESCRIPTION :The DS1307 Serial Real Time Clock is a low power, full BCD clock/calendar plus 56 bytes of nonvolatile SRAM. Address and data are transferred serially via a 2–wire
bi–directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with less than 31 days, including corrections for leap year. The clock operates in either the 24–hour or 12–hour format with AM/PM indicator. The DS1307 has a built–in power sense circuit which detects power failures and automatically switches to the battery supply.
The DS1307/1308 operates as a slave device on the serial bus. Access is obtained by implementing a START condition and providing a device identification code followed by a register address. Subsequent registers can be accessed sequentially until a STOP condition is
executed. When VCC falls below 1.25 x VBAT the device terminates an access in progress and resets the device address counter. Inputs to the device will not be recognized at this time to prevent erroneous data from being written to the device from an out of tolerance system.
When VCC falls below VBAT the device switches into a low current battery backup mode. Upon power up, the device switches from battery to VCC when VCC is greater than VBAT+0.2V and recognizes inputs when VCC is greater than 1.25 x VBAT.
ds1307 uses 32.768 Khz crystal.
PROGRAM CODE: Code is written in KEIL C. I2c functions are copied from dallas application notes. The program displays time for 6 seconds, and temperature for 4 seconds, and goes like this. The displays are four multiplexed seven segment led displays. The source code and schematic are provided at the end of the documentation.
Any questions are welcome.
prepared by: Ruksen Inanir
Dokuz Eylul University Electronics Engineering Department Student