Shop OBEX P1 Docs P2 Docs Learn Events
parallel data transfer.... can someone help ? (newbie) — Parallax Forums

parallel data transfer.... can someone help ? (newbie)

StratosStratos Posts: 15
edited 2010-07-23 04:27 in Propeller 1
·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

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-07-18 22:16
    change
    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
  • StratosStratos Posts: 15
    edited 2010-07-19 08:10
    Thanks John!!! That was it ! I spend many hours on this ! ... because I decided not to read the manual before starting this project...
  • StratosStratos Posts: 15
    edited 2010-07-19 12:52
    more problems..Actually problem has been solved in half!? First time data is sent OK, second time all data stay the same!!! but the program still runs.
    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 ???
  • Mike GMike G Posts: 2,702
    edited 2010-07-19 13:17
    It's better if you post all your code, it's not clear what you're doing. However, it might be better to replace

    repeat while acknowledge[noparse][[/noparse]0] == 0
       acknowledge[noparse][[/noparse]0]:=ina[noparse][[/noparse]11]    
    
    


    with
    repeat while ina[noparse][[/noparse]11] == 0  
    acknowledge[noparse][[/noparse]0]:=ina[noparse][[/noparse]11]
    
    


    The way the repeat logic is coded you must initialize acknowledge[noparse][[/noparse]0] := 0 before entering the repeat loop.
  • StratosStratos Posts: 15
    edited 2010-07-22 08:32
    Hi Mike! you were correct...that was the problem. it would enter the loop and then immediatelly exit. The funny thing is that I changed to:


    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!
  • AribaAriba Posts: 2,690
    edited 2010-07-23 04:27
    Stratos

    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
Sign In or Register to comment.