Page 126 - Making PIC Microcontroller Instruments and Controllers
P. 126
'fi6 CtocKs. MEMORY. AllD SOCIGIS
c8
0.1
A2 scL
SDA
I2C SEEPBOM
(Wiring and circuitrv
ffi*t$ l2C SEEPROM. requirements.)
Program to read trom and write to l2c SEEPROMS
eliijffi!!&t$S
;This mictoEngrineerinqt Lalrs progrd be found on rheir
;Web site. Use lhe lates! version.
CLE]AR
€o coN 0 define serial oulput Pin
N2{00 coN 4 seE serial node
def,ne variables
DPITI VAR PORTA. O I2c daia pin
CPIN VAR PORTA.I
BO 1IAR EYTE variabLe declararion
81 1IAR EYITE wariable declaration
82 VAR BYTTE variable declaration
write to El}e nenory
F o R B 0 = 0 T o 1 5
r2cwRltE DPIN, CPX[, sAo, B0' IBo] write each location's
address to itself
PAUSE 10 deLay 10 ns after each
urite is needed
NEXT BO
FOR BO - 0 TO 15 STEP 2
I2CREJtrD DPIN, CPIN, $AO, BO, IEl, 827 read 2 tocations rn
" ^'1/82'" prlnt 2 Localions !o
SEROUI'! SO, N2400, I*BL,
CRT
NEXT AO
SEROUT SO, N2400, [13,10] print a line feed
GOEO LOOP
EMD