Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Timing / Output frequency — Parallax Forums

Propeller Timing / Output frequency

heathclfheathclf Posts: 43
edited 2008-05-20 16:03 in Propeller 1
I'm running a propeller chip at 80MHz, and am trying to see how precise I can get some timing. I tried :

T1 := cnt
waitcnt(1 + cnt)
T2 := cnt
dT := T2 - T1
outa[noparse][[/noparse]9..4] := dT

Hoping that only a few ticks would go by, and I could see the binary number on my LEDs but had to wait much much longer in order for it to even execute fully, which is a little confusing, as cnt is supposed to keep track of each 'tick' and I thought I remembered reading that each instruction was 4 ticks.


So then, I hooked it up to a function generator (this time running the paralax at 80MHz), to see how fast of a wave I could output and using code similar to:

repeat
!outa[noparse][[/noparse]pin]
waitcnt(TimeDelay + count)

could only get a square wave with a high time and low time of 390 counts each (~17kHz square wave). The wave is nearly perfectly square, and so I don't get why I can't get it to execute faster than that.

Any help with these two very similar questions would be greatly appreciated.

Thanks

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-05-16 20:42
    Assembly instructions can execute as fast as four clocks each. Spin instructions, because they're interpreted, take much longer.

    -Phil
  • heathclfheathclf Posts: 43
    edited 2008-05-16 22:15
    I sort of assumed that, but 390 clicks to flip a bit? Really? That seems a little crazy.

    Does anyone know when the assembly documentation is supposed to be completed?

    Thanks.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-16 23:10
    If you do a WAITCNT(1 + CNT), the wait misses the time specified and has to wait for CNT to wraparound at 32 bits which takes about 50 seconds with an 80MHz clock. The manual discusses minimum wait times. In assembly, you can get away with times as short as a few clock cycles (6-8 I think). Spin is about 100 times slower. I would use a minimum time offset of a couple of hundred clock cycles at least.

    You can generate much faster pulses in Spin using the built-in counters.· Check out the Frequency Synthesis object in the Propeller Object Exchange.
    ·
  • Cluso99Cluso99 Posts: 18,069
    edited 2008-05-17 04:02
    Here is a piece of code I use to pulse a pin at 100nS.

    I normally use it as an object, so have modified it to work standalone.
  • heathclfheathclf Posts: 43
    edited 2008-05-19 03:26
    Hey, thanks a lot, Mike and Cluso.
  • nohabnohab Posts: 96
    edited 2008-05-20 14:50
    I can't re-find it now, but somewhere I've read that waitcnt(391+cnt) is the minimum value

    /Nicke
  • heathclfheathclf Posts: 43
    edited 2008-05-20 16:03
    I can get 390 + cnt to work. But nothing less.
Sign In or Register to comment.