Shop OBEX P1 Docs P2 Docs Learn Events
need help with PASM — Parallax Forums

need help with PASM

TimHTimH Posts: 48
edited 2009-09-03 11:35 in Propeller 1
This is my first attempt at PASM with the propeller. I've studied various examples in this forum but have hit a wall.
I want to monitor a pin (15) for a pulse - (high). When detected I want to output another pulse after a delay on pin 16.
The output section works fine if I comment the 3 lines after :loop.
I'm sure its a simple error but I cannot see it.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2009-09-03 03:09
    TimH said...
    ... The output section works fine if I comment the 3 lines after :loop.
    I'm sure its a simple error but I cannot see it.

    Try this:

    :loop
                    mov       read_port, ina                 'look for a pulse on Key In (15). If not then keep
                    test      read_port,pinmask_in  wz       'looking else continue with output key.
                    tjz       read_port,#:loop               'Mask all but pin 15 - loop if zero (no key in)
    
    



    You could also use this to the same effect:

    :loop
                    waitpeq   pinmask_in, pinmask_in         'look for a pulse on Key In (15). If not then keep
    
    



    Another variation:

    :loop
                    test     pinmask_in,ina  wz              'look for a pulse on Key In (15). If not then keep looking else continue with output key.
                    tjz       read_port,#:loop               'Mask all but pin 15 - loop if zero (no key in)
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve

    Propeller Tools Post Edited (jazzed) : 9/3/2009 3:30:00 AM GMT
  • TimHTimH Posts: 48
    edited 2009-09-03 03:20
    Thanks Steve

    The first change did not work but the 2nd did.

    I need to go back to the manual and try to figure out why.
  • jazzedjazzed Posts: 11,803
    edited 2009-09-03 03:26
    Maybe the pulse is too fast for the loop. Assuming 80MHz operation, the first one takes 150ns, the test
    alternative I added last takes 100ns, waitpeq detects smaller pulses .... How much smaller? Don't remember.

    Glad you have something working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve

    Propeller Tools
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-09-03 03:34
    TimH,

    In your original code change...

    read_port         long
    
    



    ...so that it reads...

    read_port         long      0
    
    




    ... and that will solve your error.
    The way it is, pinmask_key is assigned to the read_port value and gets overwritten when you change read_port which corrupts the pinmask_key value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 9/3/2009 4:29:09 AM GMT
  • jazzedjazzed Posts: 11,803
    edited 2009-09-03 03:47
    Ouch! read_port and pinmask_key are the same address without the added 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve

    Propeller Tools
  • TimHTimH Posts: 48
    edited 2009-09-03 11:35
    Steve & Beau

    Thanks for your help - there's certainly plenty of scope for errors with PASM. I'm sure once you've spend a few hours tracking a problem its not easily forgotten though.

    Tim
Sign In or Register to comment.