Shop OBEX P1 Docs P2 Docs Learn Events
CLKSET and synchronized delays on more cogs — Parallax Forums

CLKSET and synchronized delays on more cogs

tmarkotmarko Posts: 1
edited 2009-07-04 05:42 in Propeller 1
Hello, I have problem.
I want to sending 2 different high frequency pulses (propeller must run high·XTAL1 + PLL16X frequency during generating pulses) in differnet·periods. So i am using·two cogs.·Delays betwen pulses of one frequency must be synchronized.

During delays, for battery saving,·I·need to·change·propeller frequency to low XTAL1.
The problem is that when the CLKFREQ of propeller is changed to high freq during delay, CNT is rising faster and the delay is shorter.

So if I start·WAITCNT·delay after first pulse(low freq on XTAL1) and send signal from secound cog during waiting(high freq) delay will be shorter.

Have you got some idea how to sort out this problem? thanks

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-07-03 09:04
    Do we already talk about PASM or is it SPIN?
    What is the pulse-time/pause-time that we talk about?

    Maybe you can setup a counter to count clock frequency independend. You simply set the phase depending on the clockfrequency. High frequency = low phase-value, low frequency = high phase-value. Of course you have to implement you own waitcnt which then waits for the right value in the frequency register. If this is doable very much depends on the time we talk about.
  • matbmatb Posts: 39
    edited 2009-07-04 05:42
    It would be much much simpler to use one cog to generate both pulses.

    Either just do it in code, calculating the next pin change, and changing the clock as required.

    An even better way is to use a cogs counters. The counters can generate a much more accurate pulses than twiddling bits in code. This might be enough to let you just leave it in PLLx1 all the time. If you still need to change the clock, use a WAITPNE to detect either counter pulse, then change the clock and adjust the counters as required.

    If you change do the clock, you generally need to coordinate the change with ALL the WAITCNT's and some counter logic running on all COGs. That could be as simple as just stopping and restarting them.

    Post Edited (matb) : 7/4/2009 5:50:48 AM GMT
Sign In or Register to comment.