3.2 Memory Modules: SERIAL CLOCK (SCL) : The SCL Input Is Used To Positive Edge Clock Data Into Each
3.2 Memory Modules: SERIAL CLOCK (SCL) : The SCL Input Is Used To Positive Edge Clock Data Into Each
2 Memory Modules
In this project, the microcontroller is interfaced with two memory modules. One for
storing the setting details, tariff details and balance amount s etc. and the second memory is
included in the smart card which holds the recharge amount. Once the smart card is detected, the
controller checks the memory for its validity, and if it’s a valid card the amount is read from the
memory location and adds and store into the built in memory’s balance amount location. Once
the amount is read from the smart card memory, the controller will erase the memory part and
make it invalid for further reusing.
The memory modules are built upon the serial eeprom chips AT24Cxx series, and
communicate with the controller with the help of I2C protocol. The AT24C01/02/04/08/16
provides 1024/2048/4096/8192/16384 bits of serial electrically erasable and programmable read-
only memory (EEPROM) organized as 128/256/512/1024/2048 words of 8 bits each. The device
is optimized for use in many industrial and commercial applications where low-power and low-
voltage operation are essential. The AT24C01/02/04/08/16 is available in space-saving 8-lead
PDIP, 8-lead JEDEC SOIC, 8-lead Ultra Thin Mini-MAP (MLP 2x3), 5-lead SOT23
(AT24C01A/AT24C02/AT24C04), 8-lead TSSOP, and 8-ball dBGA2 packages and is accessed
via a Two-wire serial interface. In addition, the entire family is available in 2.7V (2.7V to 5.5V)
and 1.8V (1.8V to 5.5V) versions.
SERIAL DATA (SDA): The SDA pin is bidirectional for serial data transfer. This pin is open-
drain driven and may be wire-ORed with any number of other open-drain or open-collector
devices.
DEVICE/PAGE ADDRESSES (A2, A1, A0): The A2, A1 and A0 pins are device address
inputs that are hard wired for the AT24C01A and the AT24C02. As many as eight 1K/2K
devices may be addressed on a single bus system (device addressing is discussed in detail under
the Device Addressing section). The AT24C04 uses the A2 and A1 inputs for hard wire
addressing and a total of four 4K devices may be addressed on a single bus system. The A0 pin is
a no connect and can be connected to ground. The AT24C08A only uses the A2 input for
hardwire addressing and a total of two 8K devices may be addressed on a single bus system. The
A0 and A1 pins are no connects and can be connected to ground. The AT24C16A does not use
the device address pins, which limits the number of devices on a single bus to one. The A0, A1
and A2 pins are no connects and can be connected to ground.
WRITE PROTECT (WP): The AT24C01A/02/04/08A/16A has a Write Protect pin that
provides hardware data protection. The Write Protect pin allows normal Read/Write operations
when connected to ground (GND). When the Write Protect pin is connected to VCC, the write
protection feature is enabled.
START CONDITION: A high-to-low transition of SDA with SCL high is a start condition
which must precede any other command.
STOP CONDITION: A low-to-high transition of SDA with SCL high is a stop condition. After
a read sequence, the stop command will place the EEPROM in a standby power mode .
ACKNOWLEDGE: All addresses and data words are serially transmitted to and from the
EEPROM in 8-bit words. The EEPROM sends a zero to acknowledge that it has received each
word. This happens during the ninth clock cycle.
Figure : Acknowledge
MEMORY RESET: After an interruption in protocol, power loss or system reset, any 2-wire
part can be reset by following these steps:
1. Clock up to 9 cycles.
2. Look for SDA high in each cycle while SCL is high.
3. Create a start condition.
The data word address lower three (1K/2K) or four (4K, 8K, 16K) bits are internally
incremented following the receipt of each data word. The higher data word address bits are not
incremented, retaining the memory page row location. When the word address, internally
generated, reaches the page boundary, the following byte is placed at the beginning of the same
page. If more than eight (1K/2K) or sixteen (4K, 8K, 16K) data words are transmitted to the
EEPROM, the data word address will “roll over” and previous data will be overwritten.
ACKNOWLEDGE POLLING: Once the internally timed write cycle has started and the
EEPROM inputs are disabled, acknowledge polling can be initiated. This involves sending a start
condition followed by the device address word. The read/write bit is representative of the
operation desired. Only if the internal write cycle has completed will the EEPROM respond with
a zero allowing the read or write sequence to continue.
RANDOM READ: A random read requires a “dummy” byte write sequence to load in the data
word address. Once the device address word and data word address are clocked in and
acknowledged by the EEPROM, the microcontroller must generate another start condition.
The microcontroller now initiates a current address read by sending a device address with the
read/write select bit high. The EEPROM acknowledges the device address and serially clocks out
the data word. The microcontroller does not respond with a zero but does generate a following
stop condition.
SEQUENTIAL READ: Sequential reads are initiated by either a current address read or a
random address read. After the microcontroller receives a data word, it responds with an
acknowledge. As long as the EEPROM receives an acknowledge, it will continue to increment
the data word address and serially clock out sequential data words. When the memory address
limit is reached, the data word address will “roll over” and the sequential read will continue. The
sequential read operation is terminated when the microcontroller does not respond with a zero
but does generate a following stop condition.
The AT24C08 is a 1024 Byte I2C based serial eeprom memory, integrated in a 8 pin
PDIP package. The main pins for the I2C communication, SDA (serial data line) and SCL (Serial
Clock line) are connected to the microcontroller’s P2.0 and P2.1 respectively. To avoid the
issues due to the in bus capacitance, the SDA and SCL pins are pulled up to the VCC through the
10K resistors. The hardware addressing pins of the I2C memory chip, A0, A1 and A2 are
connected to the GND line, so that the hardware address will remain A0. The write protection
feature is disabled by connecting the WP pin to the GND. To avoid the transient nose influences
on the power supply, a .1uF bypass capacitor is connected near to the VCC pin.