Shop OBEX P1 Docs P2 Docs Learn Events
Waitcnt in PASM — Parallax Forums

Waitcnt in PASM

MacTuxLinMacTuxLin Posts: 821
edited 2012-01-12 10:07 in Propeller 1
Hi All,

Please help me to figure out microseconds waiting in PASM
' ---------------------
' Pause in 0.1 microseconds
' ---------------------
' 
pauseus                 mov     ustimer, cnt                    ' sync with system clock
                        sub     ustimer, #24                    ' account for setup/call/return
                        add     ustimer, o1ustix                ' set timer for 0.1 us
usloop                  waitcnt ustimer, o1ustix                ' wait and reload
                        djnz    usecs, #usloop                  ' update delay count
pauseus_ret             ret



I got o1ustix := clkfreq / 10_000_000. At 80MHz, o1tix would = 8 ticks. Since waitcnt takes 5 ticks & djnz takes 4, does it means I would be waiting 1 extra tick for each loop?? Thanks.

Comments

  • JonnyMacJonnyMac Posts: 9,198
    edited 2012-01-12 09:45
    That may be cutting it too fine, especially since you have overhead for the call and return (the reason for the sub ustimer, #24). I believe you have a couple of strict timing values for your program. Pre-calculate those (in Spin) and pass them to your PASM object for use with in-line delays using waitcnt.

    Since you're new to PASM it may be useful to post the spec of the device you're trying to connect to; that would allow others to office specific code you could learn from.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2012-01-12 10:07
    Thanks Jon. I've spent the whole day yesterday reading & understanding your code & it really helped me draft out my first PASM code.

    You're right, its 2am now & I've yet to finish up the read / write routine. Its a at88sa102s. Its high & low pulse duration signal is =< 4.56 & => 4.1 usec. I think it ought to be possible to replace the tinymega85 (default setup to comm with this device) with a cog & a pin. It'll be a life-saver for me if someone has a working code for this device.

    Thanks.
Sign In or Register to comment.