Shop OBEX P1 Docs P2 Docs Learn Events
Found solution to - Having trouble determining elapsed time with pasm — Parallax Forums

Found solution to - Having trouble determining elapsed time with pasm

Marc GebauerMarc Gebauer Posts: 60
edited 2009-03-05 18:54 in Propeller 1
*** 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

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2009-03-05 04:54
    CNT does not start from 0. It is 32 bits continually incrementing counter. You would be better to do

    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
  • Marc GebauerMarc Gebauer Posts: 60
    edited 2009-03-05 04:58
    I don't want to stop the cog. I need to keep processing until the time limit is exceeded. Plus I want to set the time limit by calling a spin routine from·top object.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Marc Gebauer) : 3/5/2009 5:08:55 AM GMT
  • KyeKye Posts: 2,200
    edited 2009-03-05 05:12
    Okay, don't use cmps, infact, don't use signed operations unless you really need them in the operation. In the situation you're using it in counter value is not signed.
    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
  • Marc GebauerMarc Gebauer Posts: 60
    edited 2009-03-05 05:16
    I tried cmp and that did not work either.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • KyeKye Posts: 2,200
    edited 2009-03-05 05:17
    I edited my post.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Marc GebauerMarc Gebauer Posts: 60
    edited 2009-03-05 18:54
    Studied how bit time was determined in Fullduplex serial and came up with the solution to my problem. See original post.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.