How To Interface The 24LC256 EEPROM To Arduino
How To Interface The 24LC256 EEPROM To Arduino
The 24LC256 EEPROM: The Microchip 24LC256 is a 32K x 8 (256 Kbit) Serial Electrically Erasable P !M" capable o# operatio$ across a broa% &olta'e ra$'e (()*+ to 5)5+)) ,t has bee$ %e&elope% #or a%&a$ce%" lo-. po-er applicatio$s s/ch as perso$al co00/$icatio$s or %ata ac1/isitio$) This %e&ice also has a pa'e -rite capability o# /p to 64 bytes o# %ata) This %e&ice is capable o# both ra$%o0 a$% se1/e$tial rea%s /p to the 256K bo/$%ary) 2/$ctio$al a%%ress li$es allo- /p to ei'ht %e&ices o$ the sa0e b/s" #or /p to 2 Mbit a%%ress space) This %e&ice is a&ailable i$ the sta$%ar% 8.pi$ plastic 3,P" S!,C" TSS!P" MS!P a$% 324 pac5a'es)
Feature :
Si$'le S/pply -ith !peratio$ 3o-$ to 2)5+ #or 24LC256 3e&ices Lo-.Po-er CM!S Tech$olo'y6 7 8cti&e c/rre$t 499 /8" typical 7 Sta$%by c/rre$t (99 $8" typical 2.:ire Serial ,$ter#ace" ,2C; Co0patible Casca%able /p to Ei'ht 3e&ices Sch0itt Tri''er ,$p/ts #or 4oise S/ppressio$ !/tp/t Slope Co$trol to Eli0i$ate <ro/$% =o/$ce (99 5>? a$% 499 5>? Cloc5 Co0patibility Pa'e :rite Ti0e 5 0s 0ax) Sel#.Ti0e% Erase@:rite Cycle
Pinout: The 24LC256 EEP !M has the pi$o/t sho-$ i$ the #ollo-i$' pict/res6
( 9 ( 9 82 8( 89 x
So i# yo/ co$$ect pi$s 89" 8(" 82 to <43 the ,2C a%%ress -ill be (9(9999 A 9B59 i$ hexa%eci0al)
The $P pi$ is C-rite protectD" set this lo- #or rea%@-rite or hi'h #or rea% o$ly) :e are 'oi$' to li$5 it to <43) Pi$ %cc -ill recei&e the E5+) Pi$ % is the <43)
&CL and &'A pi$s are the pi$s /se% by the ,2C b/s)
(nterfacin) with Arduino To i$ter#ace the 24LC256 chip to 8r%/i$o , %e&elope% a si0ple boar% /si$' a stripboar%) ,t is sho-$ i$ the #ollo-i$' pict/re6
,# yo/ %eci%e to b/il% this boar%" re0eber that the copper trac5s shall be o$ the botto0 si%e so -he$ yo/ c/t the trac5s yo/ ha&e to 0irror the abpo&e pict/re) 4o- yo/ ha&e to co$$ect" -ith so0e -ires" yo/r 8r%/i$o -ith this boar%)
GND <--> DA CL 5V <--> <--> <--> GND A4 A5 5V
4o- letFs 0a5e so0e test" the co%e to %o the test is &ery si0ple6
#include <Wire.h> // for I2C #define i2caddr !5 // de"ice addre## for lef$-hand chi% on our &read&oard &'$e d( ) // da$a $o #$ore in or read fro* $he ++,-./ "oid setup01 2 Serial.&e3in04452 Wire.&e3in01)
Serial.%rin$ln08Wri$in3 da$a...81) for 0in$ i( ) i<2 ) i991 2 6ri$eDa$a0i:i1) ; Serial.%rin$ln08D.N+81) Serial.%rin$ln08-eadin3 da$a...81) for 0in$ i( ) i<2 ) i991 2 Serial.%rin$0i1) Serial.%rin$08 < 81)
d(readDa$a0i1) Serial.%rin$ln0d: D+C1) ; Serial.%rin$ln08D.N+81) ; // 6ri$e# a &'$e of da$a in *e*or' loca$ion addr "oid 6ri$eDa$a0un#i3ned in$ addr: &'$e da$a1 2 Wire.&e3in=ran#*i##ion0i2caddr1) // #e$ $he %oin$er %o#i$ion Wire.6ri$e00in$10addr >> >11) Wire.6ri$e00in$10addr ? !@@11) Wire.6ri$e0da$a1) Wire.end=ran#*i##ion01) dela'04 1) ; // read# a &'$e of da$a fro* *e*or' loca$ion addr &'$e readDa$a0un#i3ned in$ addr1 2 &'$e re#ul$) Wire.&e3in=ran#*i##ion0i2caddr1) // #e$ $he %oin$er %o#i$ion Wire.6ri$e00in$10addr >> >11) Wire.6ri$e00in$10addr ? !@@11) Wire.end=ran#*i##ion01) Wire.reAue#$@ro*0i2caddr:41) // 3e$ $he &'$e of da$a re#ul$ ( Wire.read01) re$urn re#ul$) ; "oid loop01 2 ;
,# all is -or5i$' #i$e the o/tp/t o$ the serial li$e sho/l% be as #ollo-s6