Shop OBEX P1 Docs P2 Docs Learn Events
How high does the system counter count? — Parallax Forums

How high does the system counter count?

idbruceidbruce Posts: 6,197
edited 2011-01-06 21:11 in Propeller 1
Hello Everyone

I need to sync. I have a function that starts a new cog, I need that function and that cog to sync with the system clock. So in other words, I want both the function and the cog to pause execution until they can both start at the same time according to the system clock.

Thanks in advance.

Bruce

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-01-06 19:51
    You pick a system clock time enough in the future so that both cogs will be done with whatever setup they need before the time comes. Both cogs then do a WAITCNT on the same value. When the WAITCNTs finish (simultaneously), the two cogs will be synchronized. Note that the system clock wraps around at 2 ^ 32. That's not an issue for the WAITCNTs because the WAITCNTs do a compare for equality. Essentially, you do "StartTime := waitTime + CNT" where waitTime is the number of system clocks to wait, then both cogs do WAITCNT(StartTime).
  • idbruceidbruce Posts: 6,197
    edited 2011-01-06 19:58
    Thanks a lot Mike

    I think I grasp that. But do I pass StartTime as a pointer or just a varible to the other cog?

    Bruce
  • idbruceidbruce Posts: 6,197
    edited 2011-01-06 20:14
    ElectricAye

    Thanks for pointing that out to me, that was very interesting. Have you been using Stefans code? And what do you mean see page 73?

    Bruce
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-01-06 21:07
    idbruce wrote: »
    ElectricAye

    Thanks for pointing that out to me, that was very interesting. Have you been using Stefans code? And what do you mean see page 73?

    Bruce

    Bruce,
    never mind page 73 - it really doesn't tell you much.
    You'll notice the thread I linked to is over 2 years old, so I don't remember if I ever used Stefan's code per se, but the concept of taking a "snapshot" of the system clock and working with it downstream I think is a valid one. I probably learned it from him, but I just don't recall exactly.

    Take special note of what Mike Green has said above.
  • idbruceidbruce Posts: 6,197
    edited 2011-01-06 21:11
    ElectricAye

    I took Mikes suggestion and it worked perfectly. The stepper driver now has steps and pulses that are equal, but it is still giving me two extra steps and pulses. Should not be too hard to find. Anyhow thanks for the info, I appreciate it.

    Bruce
Sign In or Register to comment.