Shop OBEX P1 Docs P2 Docs Learn Events
prob w\ ping assm looping — Parallax Forums

prob w\ ping assm looping

ratronicratronic Posts: 1,451
edited 2007-08-02 03:23 in Propeller 1
I am trying to get this code to loop for my own assm knowledge. I can only make it ping one time. I have looked
through the forums, stickies, and prop manual for direction and have tryed everything I can think·of.
It doesn't have returning values yet, but I will put them in later. I would just like it to loop for now so·it continously pings.·Attached file is commented for what I am attempting. This routine can be called by itself or from a demo routine for now. Please help as I am completely brain dead! I have spent many hours trying to figure this thing out. Thanks Dave

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Fix it if ain't broke·
D Rat


Dave Ratcliff· N6YEE

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-31 20:42
    A couple of things ...

    1) You don't set the clock mode anywhere or the crystal frequency (_CLKMODE, _XINFREQ). That means it's using RCFAST.

    2) The WAITPNE is backwards. You probably mean "waitpne msk,#0" to test for a high and "waitpeq msk,#0" to test for a low.

    3) On the WAITCNT, you don't need to put anything other than "#0" in the source field since you're recalculating the delay time each time.
  • ratronicratronic Posts: 1,451
    edited 2007-07-31 22:34
    Thanks Mike!!!· I was calling from a simple demo routine w/ the clock set right, but then was calling directly and for got to set clock in aping.spin routine. The waitpne & peq was a stupid mistake on my·part. And thanks for the
    example on the waitcnt, it really helps me to understand the waitcnt better now that I've have correct info from an expert that I trust! But it still doesn't loop. I have tryed it on the demo board and my own dip prop breadboard
    using the parallax 7.5v 1amp supply and the power supplys are up to snuff. I have made code that toggles p16 with a waitcnt and it works. There must be one more thing I am missing. I have attached the recent corrected code using your advice.· If you could have one more look at it I would appreciate it!! I have tryed to figure it out before I responded back. It looks as if it should work. I am getting just one blink of the green lite on the ping and one blip on the scope. The green lite on the senor·changes intensity each time I run it depending how close my hand is to sensor. I just can't get it loop continuosly. This is for nothing in particular but for me to gain knowledge in assm and I did look at the code before·I·responded back but now my eyes are crossed!! Thanks for your help, Dave.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
  • AribaAriba Posts: 2,685
    edited 2007-08-01 07:42
    It does not loop because of the waitpne/waitpeq instruction. The mask is the second parameter !
    Instead of:
               waitpne msk, #0         'wait for p0 hi
                  ...
               waitpeq msk, #0         'wait for p0 low
                  ...
    
    


    use this:
               waitpeq msk,msk         'wait for p0 hi
                  ...
               waitpne msk,msk         'wait for p0 low
                  ...
    
    



    Andy
  • ratronicratronic Posts: 1,451
    edited 2007-08-01 16:30
    I still can't get it to loop!! According to pages 412 & 413 in the prop manual·the·destination field has to be a register , so I would like it to be zero, there for I created·(a long 0).·The source field has to be a register or a 9 bit literal,·so I used msk which has a 1 in the·p0 position. The green lite·on the ping even though it only blinks once does change to a lower intensity the closer my hand is to the sensor. I have tryed both your examples and the some. I still can't·get the code·to loop continously. Please help!!!· Dave



    P.S. Thank you·Mike and Ariba for all your help so far! Attached is the latest code I am trying.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-01 16:42
    I noticed "sub cnt1,cnt2" ... this does the opposite of what you want. Try "sub cnt2,cnt1".

    I guess I didn't really look at what you were trying to do. You're using P0 initially as an output, then looking at it as an input, but you're never switching it back to input mode. The "waitpxx" instructions are looking at the I/O pin, but it's an output and won't change. The waitpne never succeeds since the pin is always a low at that point.
  • ratronicratronic Posts: 1,451
    edited 2007-08-01 23:36
    I still can't get this to loop!!! I commented out the "sub cnt1, cnt2" in case it is the problem of code not looping. I just hooked up my dso and will check my timing with smaller pieces of code, but I don't see anything that would keep the code from looping. It is a ping sensor I am trying get continuosly to run, I'm not worryed about getting the numbers out right now, I will take care of that later. Any more looks at it would be appreciated!! Attached is the latest code I think should work. I have tryed this w/ spin and objects from the library and the sensor works perfectly. I just wanted to try it w/ assm. Thanks!!! Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
  • ratronicratronic Posts: 1,451
    edited 2007-08-02 03:23
    I've got it looping now!!! Some things still need a little bit of changing though. I should of used the DSO from the begining. I just want say thanks to Mike and Ariba for pointing in the right direction. Thanks!!! Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
Sign In or Register to comment.