Code:
@ DEVICE HS_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
DEFINE LOADER_USED 1
DEFINE OSC 20
ADCON1 = 7
sda var PORTC.4 'I2C SDA for ext eeprom
scl var PORTC.3 'I2C SCL for ext eeprom
ctl con 160 'EEPROM control code
addr var WORD 'eeprom word address
i var byte 'Index counter
edata var BYTE 'Data byte to be written and read
out_pin var PORTC.6 'TX pin of 16F877
ser_baud con 32 '19200
addr = 0
edata = 0
pause 100
serout2 out_pin,ser_baud,["Writing to EEPROM . . .",10,13]
for i = 0 to 249
lookup i,[_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$3F,$C0,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$0F,$FA,$60,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$7C,$04,$38,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$D2,$60,$C8,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$01,$D0,$22,$1C,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$03,$A2,$80,$0C,$00,$00,$00],edata
I2CWRITE sda,scl,ctl,addr.highbyte,addr.lowbyte,[edata]
pause 10
addr = addr + 1
next
. . .
for i = 0 to 249
lookup i,[_
$00,$00,$00,$01,$FE,$1F,$9F,$E0,$7C,$07,_
$FE,$3C,$1F,$03,$80,$3F,$C0,$3C,$E0,$00,_
$7F,$DF,$FC,$14,$97,$1D,$FD,$77,$00,$1C,_
$00,$00,$00,$03,$0F,$03,$E1,$F0,$FC,$0E,_
$1E,$38,$0E,$03,$80,$61,$E0,$FD,$E0,$00,_
$77,$CD,$FC,$80,$95,$8D,$EF,$7B,$80,$1C,_
$00,$00,$00,$00,$07,$01,$C0,$F0,$1C,$1C,_
$04,$38,$0E,$03,$80,$00,$E0,$1E,$00,$00,_
$7F,$DF,$6E,$2E,$BC,$CE,$FF,$BE,$80,$1C,_
$00,$00,$00,$00,$07,$01,$C0,$70,$1C,$18,_
$00,$38,$0E,$03,$80,$00,$E0,$1C,$00,$00,_
$7D,$4F,$FF,$81,$37,$3B,$FB,$F8,$80,$1C,_
$00,$00,$00,$00,$07,$01,$C0,$70,$1C,$38,_
$00,$38,$0E,$03,$80,$00,$E0,$1C,$00,$00,_
$5F,$E5,$BB,$CA,$2F,$FE,$FF,$F4,$80,$1E,_
$00,$00,$00,$00,$3F,$01,$C0,$70,$1C,$38,_
$00,$38,$0E,$03,$80,$07,$E0,$1C,$00,$00,_
$6F,$AF,$FF,$C1,$7E,$FE,$BF,$C7,$00,$0E,_
$00,$00,$00,$01,$E7,$01,$C0,$70,$1C,$38,_
$00,$38,$0E,$03,$80,$3C,$E0,$1C,$00,$00,_
$3D,$E3,$F7,$E0,$6B,$57,$F7,$C3,$00,$0F,_
$00,$00,$00,$43,$07,$01,$C0,$70,$1C,$38,_
$00,$38,$0E,$03,$80,$60,$E0,$1C,$00,$00,_
$2F,$EA,$DD,$FE,$D9,$BF,$BD,$F3,$00,$07,_ '1231 to 1240
$80,$00,$01,$CE,$07,$01,$C0,$70,$1C,$3C],edata
I2CWRITE sda,scl,ctl,addr.highbyte,addr.lowbyte,[edata]
pause 10
addr = addr + 1
if addr > 1230 and addr < 1241 then
serout2 out_pin,ser_baud,[dec addr,44,32,hex2 edata,72,10,13]
endif
next
. . .
for i = 0 to 169
lookup i,[_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$03,$C0,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00],edata
I2CWRITE sda,scl,ctl,addr.highbyte,addr.lowbyte,[edata]
pause 10
addr = addr + 1
next
serout2 out_pin,ser_baud,["Reading EEPROM . . .",10,13]
for addr = 1231 to 1240
i2cread sda,scl,ctl,addr.highbyte,addr.lowbyte,[edata]
serout2 out_pin,ser_baud,[dec addr,44,32,hex2 edata,72,10,13]
next
serout2 out_pin,ser_baud,["Finished",10,13]
end
Bookmarks