I am trying to write just 3, byte sized variables to the external eeprom and recall them at power up.
heres the data sheet for my eeprom:
http://www.datasheetarchive.com/sear...c46&sType=part
what should my trisB and TRISC be?? are they all outputs except for D0 (data out on epprom)
CS - PORTB.1
CLK - PORTB.2
D1 - PORTC.6
D0 - PORTC.7
this is what i have so far:
include "modedefs.bas"
D var byte
T var byte
ED var byte
addr var word
B0 var byte
eeread:
for addr = 0 to 2 'eeprom address
PORTB.1 = 1 'cs = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$03, addr.byte1, addr.byte0]
PORTB.1 = 0 'cs = 0
PAUSE 1
PORTB.1 = 1
Shiftin PORTC.7, PORTB.2, MSBPRE, [B0]
PORTB.1 = 0
if addr = 0 then
d = B0
endif
if addr = 1 then
t = B0
endif
if addr = 2 then
ED = B0
endif
next addr
return
eewrite:
for addr = 0 to 2
if addr = 0 then
B0 = D
endif
if addr = 1 then
B0 = T
endif
if addr = 2 then
B0 = ED
endif
PORTB.1 = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$06]
PORTB.1 = 0
PAUSE 1
PORTB.1 = 1
Shiftout PORTC.6, PORTB.2, MSBFIRST, [$02, addr.byte1, addr.byte0, B0]
PORTB.1 = 0
next addr
return
this is not all the code, but i want "encapsulated" SUBs that will take care of the reading and writing to the eeprom. so that is all i have shown.![]()
Bookmarks