Shop OBEX P1 Docs P2 Docs Learn Events
AN001 questionable — Parallax Forums

AN001 questionable

HarleyHarley Posts: 997
edited 2010-01-11 21:19 in Propeller 1
I'm questioning AN001, page 18 PASM code.

Shouldn't the ':loop' label be two lines above (at the 'mov cnt_, cnt' lline? (Is there no reason to reload 'cnt' value prior to the following 'waitcnt' events?)

DAT
org
entry    mov    ctra, ctra_    'establish mode and start counter
    mov    frqa, #1    'increment for each edge seen
    mov    cnt_, cnt    'setup time delay
    add    cnt_, cntadd
:loop    waitcnt cnt_, cntadd    'wait for next sample
    mov    new, phsa    'record new count
    mov    temp, new    'make second copy
    sub    new, old    'get delta
    mov    old, temp    'set next delta's base
    wrlong new, par
    jmp    #:loop

ctra_    long    %01010 << 26 + 7    'mode + APIN
cntadd long    80_000_000    'wait 1 second, answer in Hz
cnt_    res    1    'next count to wait on
new    res    1
old    res    1
temp    res    1




Thanks for all comments on this.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Comments

  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-11 21:18
    No. When waitcnt finishes the value of cnt_ will be equal to cnt so there is no need to reload. Then cntadd is added to cnt_ for the next pass -- this allows one to create a synchronized delay.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-11 21:19
    No, the code is correct. The waitcnt instruction adds cntadd to cnt_ when it comes out of the wait. This keeps the interval precisely equal to cntadd every time through. This would not be the case if cnt_ were reinitialized from cnt every time through the loop.

    -Phil
Sign In or Register to comment.