Keywords: Category:
 
Using I2C Function to Read/Write AT24C02 (EzCode4E)
TIME: 2008-11-19
 
Developed by Philips, I2C(Inter-Integrated Circuit) bus is the two-wire serial bus, and it is widely used as it is simple and with high efficiency. According to this, EzCode4E v4.40 has included the I2C communication function. By using I2C function in EzCode4E, AM4E can be used to read or write external devices.
 
In this article, we introduce how to realize the writing/reading of AT24C02 by using the new I2C function in EzCode4E (v4.4).

I2C Communication Function

Data Transmission Command:
TxI2C(P5:P4:P3:P2:P1:P0,Byte,DeviceAddr, Ack)
Pn:  { Constant, register }; 0x0 <= Constant <=0xf
Byte:data size to be sent, in bytes.
P1:P0 If byte=1, data P1:P0 will be sent.
P3:P2:P1:P0 If byte=2, data P3:P2:P1:P0 will be sent.
If byte=3, data P5:P4:P3:P2:P1:P0 will be sent.
DeviceAddr:address of the receiving device in I2C.
Ack: if data is successfully sent, the value is 1; otherwise, the value is 0. When Ack=0, you should check the connection of the relevant devices.
This function sends data out through I2C wire. High byte is given priority to send out. P1:P0 is low byte; P3:P2 is high byte, and so on.
Ex
TxI2C(R1:R0,0x1,0x3,R4) ; Send out data from R1:R0 in 1 byte.
TxI2C(R3:R2:R1:R0,0x2,0x1,R4) ; Send out data from R3:R2:R1:R0 in 2 bytes.
TxI2C(13,0x1,0x3,R2) ; Send out constant 13 in one byte (0x0:0xd).

Data Reading Command

RxI2C(P5:P4:P3:P2:P1:P0,Byte,DeviceAddr, Ack)
Pn:  { register };
Byte:{1,2,3};size of the data to be read, in bytes.
DeviceAddr:Address of the device in I2C that reads data.
Ack:{register}; if data is successfully read, the value is 1; otherwise, the value is 0.
This function reads data in I2C communication. P1:P0 is stored in low byte; P3:P2 is stored in high byte, and so on.
Ex
RxI2C(R1:R0,0x1,0x3,R10) ; Receive 1 byte data and store the data at R1:R0.
RxI2C(R3:R2:R1:R0,0x2,0x1,R11);Receive 2 bytes data and store them at R3:R2:R1:R0.
 
Notes:
1.  The range of parameter byte is {1,2,3}, namely at most 3 bytes can be transferred or received per time.
2.  When writing or reading, the sequence is : P5->P4->P3->P2->P1->P0.
 

Timing Sequence Diagram for Writing (AT24C02)

Byte Write: Write a byte into the specified address per time.

 

... ...

24c.rar

ORIGIN: L.XY
BACK TO TOP PRINT ADD TO FAVORITE SUBMIT CLOSE
 
>>
 OTHERS
 
·Application Note of Recording Modes (EzCode4...
·Using Midi Background
·How to Use General I/O to Drive LCD?
·The Application of One Key One Note
·Making an LED fan by ALPHA MCU
·Using ALPHA IC in Serial Communication
·Application of the Action Function
·Using AM8EB for I2C Communication
 
>>
 RECOMMENDED
 
·About the Recording Duration of AMSR Series ...
·EzCode4E Solutions
·Application Note of Recording Modes (EzCode4...
·Using Midi Background
·The Control of Silicon Controlled Rectifier
·The Application of One Key One Note
·Portamento Effect in AM4F
 
 

About Us Contact Us Disclaimer


ICP Record : 08035793 Prepared Guangdong ICP