Found solution to - Having trouble determining elapsed time with pasm
Marc Gebauer
Posts: 60
*** Found the soulton to my problem looking at how FullDuplexSerial determined bittime. ***
I call settimelimit from my top object·which·calculates the number of ticks for·my duration in·milliseconds and stores it in the time_limit parameter:
PUB settimelimit(duration)
· time_limit := clkfreq/1000*duration+cnt
Then·the main loop of my·pasm·routine does the following:
loop
· <do this all the time>
······· rdlong timelimit, par
······· sub timelimit,cnt
······· cmps··timelimit,#0·· wc
if_nc··jmp· #loop·· 'if time has not elapsed jump to·loop
· <do this if time has elapsed>
······· jmp· #loop
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Marc Gebauer) : 3/5/2009 6:58:41 PM GMT
I call settimelimit from my top object·which·calculates the number of ticks for·my duration in·milliseconds and stores it in the time_limit parameter:
PUB settimelimit(duration)
· time_limit := clkfreq/1000*duration+cnt
Then·the main loop of my·pasm·routine does the following:
loop
· <do this all the time>
······· rdlong timelimit, par
······· sub timelimit,cnt
······· cmps··timelimit,#0·· wc
if_nc··jmp· #loop·· 'if time has not elapsed jump to·loop
· <do this if time has elapsed>
······· jmp· #loop
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Marc Gebauer) : 3/5/2009 6:58:41 PM GMT
Comments
rdlong tl,par
add tl,cnt
waitcnt tl,0
Think the above is correct (hope you get the idea).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:
· Home of the MultiBladeProps:· SixBladeProp, TriBladeProp
· Prop Tools under Development or Completed (Index)
· Emulators (Micros eg Altair, and Terminals eg VT100) - index
· Search the Propeller forums (via Google)
My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Marc Gebauer) : 3/5/2009 5:08:55 AM GMT
Use cmp, just by itself.
Also, note that the cnt just loops arround over and over again. So the comparison you're using will fail·when cnt is less than your time limit... That being said look what hapens when the counter wraps arround.
For a fix, first have some flag register for the processor in asm to start the loop. Once its started the processor should get the current value of cnt, and continaully compare that older value with the newest current until the difference is greater than the time limit. This method should always work.
You will need to add in some ability to correct abs differences addtionally.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Post Edited (Kye) : 3/5/2009 5:21:54 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔