I am getting a result of 65553 or there abouts even after a reset.
I have tried adding some pause statements to the FReset as follows:
FReset:
LOW DATAP
LOW CLK
pause 50
'pause 100
HIGH CLK
pause 50
'pause 100
HIGH DATAP
pause 50
'pause 100
LOW CLK
pause 50
'pause 100
return
with no luck.
I have also tried SLOWMSBPRE for the ShiftIn/ShiftOut with no luck.
I stopped playing with it when the chip started to feel warm. I am not sure if that is normal or not, but it was enough to make me wait until I received some outside help. The chip is still working when reattached to a Basic Stamp II. It has always been a little glitchy but I think that might be wiring, power or something else.
Nathan from Basic Atom suggested an OScope but I don’t have one and I don’t think the problem warrants spending $200-300 on one right now…
The code: (as you can see there are several commented out sections, these are things I have tried throughout the debug…)
[code]datap CON 3 ’ Data pin (I/O)
datapin VAR IN3
clk CON 2 ’ Clk pin (output)
i var byte
iobyte var byte
OUTPUT clk
OUTPUT datap
fpx VAR Word ’ Integer used by some routines
fpb VAR Byte ’ byte
chan VAR Nib
register VAR byte
clearreg VAR Bit
clearchan VAR Bit
GOSUB FReset
GOSUB FTotalReset
fpx=0
GOSUB FPullup
'chan=101 'pin 5 right wheel
''chan=100 'pin 4 left wheel
'register=100
'clearchan=1
'GOSUB FCommand
'PAUSE 1000
clearchan=0
clearreg=0
'loop:
chan=101
register=100
GOSUB FCommand
'serout S_Out, I9600, [dec fpx, 13]
'pause 1000
'goto loop
end
FReset:
LOW DATAP
LOW CLK
HIGH CLK
HIGH DATAP
LOW CLK
RETURN
FCommand:
fpb=(clearchan<<7) + (clearreg<<6) + (register<<3) + chan
GOSUB FSendByte
FReadWord:
pause 100
gosub shiftinH
fpx.lowbyte=iobyte
gosub shiftinH
fpx.highbyte=iobyte
serout S_Out, I9600, "fpx ", bin fpx,13]
'SHIFTIN datap,clk,SLOWMSBPRE,[fpx.LOWBYTE\8]
'pause 10
'SHIFTIN datap,clk,SLOWMSBPRE,[fpx.HIGHBYTE\8]
RETURN
FTotalReset:
fpb=%11111111
FSendByte:
iobyte=fpb
gosub shiftoutH
'SHIFTOUT datap,clk,SLOWMSBPRE,[fpb\8]
RETURN
FPullUp:
fpb=%11010000
Fscmd:
GOSUB FSendByte
fpb=fpx
GOTO FSendByte
pakclock con 10
pakclocklow con 10
shiftoutH:
output datapin
'high datapin
serout S_Out, I9600, "shiftoutH-START ", bin iobyte\8,13]
for i=0 to 7
low datapin
if (iobyte & $80) <> $80 then goto so0
high datapin
so0:
serout S_Out, I9600, "shiftoutH ", bin iobyte\8,13]
iobyte=iobyte<<1
pause pakclocklow
pulsout clk,pakclock
pause 1
next
pause 50
return
shiftinH:
input datapin
'low datapin
iobyte=0
for i=0 to 7
serout S_Out, I9600, "shiftinH ", bin iobyte\8,13]
iobyte=iobyte<<1
iobyte=iobyte | datap
pause pakclocklow
pulsout clk,pakclock
pause 1
next
return[/code]
As you can see, I also tried the home made ShiftIn/ShiftOut from the Basic Stamp ex.