I WAS AT THIS Thread just a minute ago and i wish i knew if dark solved his problem.
http://www.picbasic.co.uk/forum/showthread.php?t=1214
93c46 datasheet:
http://leonardo.caltech.edu/~ee5x/ee.../hw6/93c46.pdf
i have the same problem, but i dont know whether its my reading or writing that is flawed. I am trying to write 3 different byte sized variables to the 93c46. i have attached a pic that shows how it is all connected. I dont think that there are any pull up resistors on the CLK or CS line, not sure if this is a problem. I simply need someone to correct my subs.
here are my eeread and eewrite subs.
include "modedefs.bas"
DEFINE SHIFT_PAUSEUS 500
CS var PORTB.1 ' Chip select pin
SCK var PORTB.2 ' Clock pin
SI var PORTC.6 ' Data in pin
SO var PORTC.7 ' Data out pin
B0 var byte '<------- data to be written
addr var BYTE '<------ eeprom memory location 1,2,3
d var byte
t var byte
ed var byte
ADCON1=7 ' set all analog pins to digital
TRISA=%011000 'PORT A
TRISB=%11110001 'PORT B
TRISC=%10100000 'PORT C
eeread:
for addr = 1 to 3 'eeprom address
CS = 1
Shiftout SI, SCK, MSBFIRST, [%110\3, addr\6]
Shiftin SO, SCK, MSBPOST, [B0]
CS=0
if addr = 1 then
d = B0
endif
if addr = 2 then
t = B0
endif
if addr = 3 then
ED = B0
endif
pause 10
next addr
return
ewrite:
for addr = 1 to 3
if addr = 1 then
B0 = D
endif
if addr = 2 then
B0 = T
endif
if addr = 3 then
B0 = ED
endif
CS = 1 ' Enable serial EEPROM
Shiftout SI, SCK, MSBFIRST, [%10011\5, 0\7] ' Send write enable command
CS = 0
PAUSE 10
CS = 1 ' Enable
Shiftout SI, SCK, MSBFIRST, [%101\3, addr\6, B0] ' Send address and data
CS = 0
pause 10
next addr
Return
the ports that the CLK and CS are connected to (portb.1 and portb.2) have programmable weak internal resistors if necesary (Option_reg.7) BUT SI and SO dont. they are on port C.6 and c.7
Bookmarks