parallel data transfer.... can someone help ? (newbie)
Stratos
Posts: 15
·Hello to everybody. Can someone help me with this???· I have been trying to do simple·data-byte transfers from one micro(pic16f873) to the propeller. The inteface is exremenly simple. The propeller uses 4·bits(4 pins) to request·a byte out of·14 total. I also· added another bit(pin) for acknowledge. As soon as the pic16f873 sees the request number from the propeller, it outputs the byte and aknowledges it by setting·the bit high pin 11. I use a repeat while loop.···I·have spent a lot of hours and can't get to work. Here is the code:
····outa[noparse][[/noparse]19..16]:=%0001 '·propeller is requesting first byte ...
····· repeat while acknowledge[noparse][[/noparse]0]:=0··' here is waiting for acknowledge bit
········· acknowledge[noparse][[/noparse]0]:=ina[noparse][[/noparse]11]· '
··· temporary:=ina[noparse][[/noparse]7..0]· ' the byte can be finally transfered...
pins 19-16 used for decoding .(outputs)
pin 11 for acknowledge (input)
pins 0-7 for the byte transfer (inputs)
The program is supposed to stop and <sample> pin 11. · but it never does...even though pin 11 is low. it justs goes on.
Now If I change the line to:
·repeat while acknowledge[noparse][[/noparse]0]:=1 it freezes even though pin 11 is low!!!
if I change this line
····outa[noparse][[/noparse]19..16]:=%0001 '·propeller is requesting first byte ...
····· repeat while acknowledge[noparse][[/noparse]0]:=0··' here is waiting for acknowledge bit
········· acknowledge[noparse][[/noparse]0]:=ina[noparse][[/noparse]11]· '
··· temporary:=ina[noparse][[/noparse]7..0]· ' the byte can be finally transfered...
pins 19-16 used for decoding .(outputs)
pin 11 for acknowledge (input)
pins 0-7 for the byte transfer (inputs)
The program is supposed to stop and <sample> pin 11. · but it never does...even though pin 11 is low. it justs goes on.
Now If I change the line to:
·repeat while acknowledge[noparse][[/noparse]0]:=1 it freezes even though pin 11 is low!!!
if I change this line
Comments
repeat while acknowledge[noparse][[/noparse]0]:=0 ' here is waiting for acknowledge bit
to
repeat while acknowledge[noparse][[/noparse]0]==0 ' here is waiting for acknowledge bit
:= is assignment == is the test for equality
John Abshier
Maybe be you can help me a bit more:
Again the propeller is like not recognizing the pin...
IF I add this line before the repeat loop
acknowledge[noparse][[/noparse]0]:=0
it works for the first time only. It took me a while to figure it out because I was sending constants to the prop. As soon as I send a variable values stay the same...
it is possible the other cogs are interfeering with the pin ???
with
The way the repeat logic is coded you must initialize acknowledge[noparse][[/noparse]0] := 0 before entering the repeat loop.
repeat
acknowledge[noparse][[/noparse]0]:=ina[noparse][[/noparse]11
while acknowledge[noparse][[/noparse]0] == 0
to force it to sample the pin once
but it never worked. I would get an error " variable expected..." so I ended up initializing like you said.
Thanks a lot!
Are you expecting to set bit 0 of acknowledge with acknowledge[noparse][[/noparse]0] ?
If so, this is not the case here. You can only access the special registers like ina, dira, outa bitwise with such a syntax.
For normal variables the [noparse]/noparse is an array access, so you set the first array element of an acknowledge array and not a single bit!
Andy