User Tools

Site Tools


tutorials:cb1:development:access_at24c_eeprom_via_i2c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tutorials:cb1:development:access_at24c_eeprom_via_i2c [2013/12/03 10:27]
soloforce
tutorials:cb1:development:access_at24c_eeprom_via_i2c [2013/12/23 14:50] (current)
Line 24: Line 24:
 This will configure Cubieboard'​s IO port PB18 & PB19 to TWI1-SCK & TWI1-SDA (I2C-1). This will configure Cubieboard'​s IO port PB18 & PB19 to TWI1-SCK & TWI1-SDA (I2C-1).
 ===== Connection ===== ===== Connection =====
-{{:​tutorials:​cb1:​development:​at24c256_circuits.png?​500 |}} +Cubieboard side will be considered as the master side of I2C communication,​ while the AT24C EEPROM devices will be considered as the slave ones. In most cases, 4 wires of connection between Cubieboard & devices are enough, they are: 
-{{:​tutorials:​cb1:​development:​i2c_detect.png?​500 |}}+  * Vcc: Cubieboard Vcc(5V) <--> AT24C Vcc 
 +  * Gnd: Cubieboard Gnd  <​--> ​ AT24C Gnd 
 +  * SDA: Cubieboard PB19 <--> AT24C SDA 
 +  * SCL: Cubieboard PB18 <--> AT24C SCL 
 +The connection of AT24C slave devices is in parallel(like the circuits below, which is a sort of write-protection AT24C configuration circuits), but they should have various device address in order to be addressed by I2C master. The addressing problem will be discussed later in this tutorial. 
 + 
 +{{:​tutorials:​cb1:​development:​at24c256_circuits.png?​500|}} 
 + 
 +Once connection is done, you can use the //​**i2c-tools**//​(apt-get install it) to detect them. If things go normal, you should get the similar result below. 
 + 
 +{{:​tutorials:​cb1:​development:​i2c_detect.png?​500|}} 
 ===== AT24C Access ===== ===== AT24C Access =====
 +AT24C series EEPROM'​s address could be splited into two parts, higher bits and lower bits. The higher bits are fixed at //​**0x5**//,​ while lower bits could be hard coded by setting //**A2, A1, A0**//'​s power logic. As for AT24C256, only A1, A0 are valid for address.
 {{:​tutorials:​cb1:​development:​at24c_pinout.png?​500 |}} {{:​tutorials:​cb1:​development:​at24c_pinout.png?​500 |}}
 ===== Example Codes ===== ===== Example Codes =====
 +This code snippet is an interactive demo for storing text strings and fetching them back to and from AT24C256 chips. Of course you can modified it to make it able to handle binary data. You maybe need install //​**libi2c-dev**//​ package to compile & run. 
 <code c> <code c>
 /* /*
Line 250: Line 263:
 {{:​tutorials:​cb1:​development:​i2c_rw.png?​500 |}} {{:​tutorials:​cb1:​development:​i2c_rw.png?​500 |}}
 <WRAP noprint> <WRAP noprint>
-{{tag>Cubieboard ​Cubietruck}}+{{tag>Cubieboard1 Cubieboard2 ​Cubietruck ​I2C AT24C EEPROM}}
 </​WRAP>​ </​WRAP>​
tutorials/cb1/development/access_at24c_eeprom_via_i2c.1386037644.txt.gz · Last modified: 2013/12/23 14:50 (external edit)