Bonsoir,,
j'ai écrit reécrit lut, mais le programme suivant ne marche pas ! pourquoi ou est mon erreur ?
merci
#picaxe-20x2
symbol dq = b.0
symbol clk = b.1
symbol rst = b.2
symbol dat=b0
dirb.1 = 1
dirb.2 = 1
' config ds1620
dat = $0c ' send command $0c followed by $02 to configure
' for CPU mode
gosub config
dat = $02
gosub config
dat = $ee ' send command $ee to cause continuous conversion
gosub config
dat = $aa' send command $aa to read data and then read
gosub config
outpinb.0 = 0
dirb.0 = 0
for b10 = 1 to 10
gosub get9bit
debug w2
next
stop
config:
for b11 = 1 to 8
'dirb.0 = 1
dirsb = %00000111
outpinb.2 = 1
b1 = dat & 01
'pause 3000
outpinb.0 = b1'dq=b1
outpinb.1 = 1' clk = 1
' outpinb.0 = 0' dq = 0
' dirb.0 = 0
dat = dat >> 1
' pause 3000
outpinb.1 = 0 ' clk = 0
next
return
get9bit:
dirsb = %00000110
for b1 = 1 to 9
outpinb.1 = 1' clk = 1
pause 100
outpinb.1 = 0' clk = 0
let b2 = pinb.0
serout 1,n2400, (10,13,"bit de ds 1620 vaut",#b2)
debug b2
pause 1000
w2 =w2 << 1
w2 = w2 or w1
next
return