Shop OBEX P1 Docs P2 Docs Learn Events
Propeller system clock performance — Parallax Forums

Propeller system clock performance

Scott LewisScott Lewis Posts: 18
edited 2008-11-17 11:58 in Propeller 1
I am not sure if the performance I am seeing is accurate. I have the propeller education board with a 5.0 MHz crystal and am using the 16x PLL to get a clock of 80 MHz. Is this clock split between all the cores, resulting in 10 MHz per core, or does each core get the whole 80 MHz.

I ran a test to see how fast a core could switch an output pin and do nothing else and i got about 43 kHz, I think it should be more than this. Here is the code I used and a screenshot from my oscilloscope.

CON
  _xinfreq = 5_000_000
  _clkmode = xtal1 + pll16x
  
var
long stack[noparse][[/noparse]20]
PUB main
  
  cognew(start(15),@stack[noparse][[/noparse]0])
    
Pub start(Pin)
  dira[noparse][[/noparse]Pin]~~
  repeat
      !outa[noparse][[/noparse]Pin]

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-11-14 22:18
    Everyone gets the 80MHz, each assembly instruction takes 4 clock cycles to execute for a throughput of 20MIPS per cog. If you want to output a fast signal you will need to program in assembly, use a counter, or use an already written object that has an assembly driver for generating frequencies.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-14 22:18
    1) All of the cores run off the system clock, so, unless they're stopped or waiting for something, they're executing most instructions every 4 clock cycles.

    2) Your program is written in Spin which is compiled into byte codes that are interpreted by a program running in a cog. The speed you're seeing is about right. If you rewrote the program in the Propeller's assembly language, you'd be able to toggle an I/O pin every 8 clock cycles (about 100ns).

    3) As Paul mentioned, you can use the cog counters (see application note #001) from either Spin or assembly language to generate pulse trains of at least 128MHz

    Post Edited (Mike Green) : 11/14/2008 10:23:57 PM GMT
  • edited 2008-11-14 22:28
    You'll also get to generating higher frequency signals with counters in the Counter Modules and Circuit Applications PE Kit Lab.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-11-14 23:49
    A follow-up to Mike's #2:
    If you use the following code:
    CON
      _xinfreq = 5_000_000
      _clkmode = xtal1 + pll16x
    
      pin = 15
      
    var
    PUB main
      
      pinum := |<15
      cognew(@start,0)
        
    DAT
    start mov dira, pinum
    loop  xor outa, pinum
          jmp #loop
    pinum LONG 0
    
    
    

    it will toggle the output pin @ 10 MHz, this is the fastest you can drive a pin from code. Using the counter can achieve frequencies up to 128 MHz when using the PLL mode of operation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Scott LewisScott Lewis Posts: 18
    edited 2008-11-15 00:05
    thanks for all the replies
  • Andrew E MileskiAndrew E Mileski Posts: 77
    edited 2008-11-17 11:58
    Mike Green said...
    3) As Paul mentioned, you can use the cog counters (see application note #001) from either Spin or assembly language to generate pulse trains of at least 128MHz
    You can also use the counters in a pseudo "one-shot" mode to generate single pulses from 1 to 2^31 cycles long (I don't think the app note mentions this specifically).

    Example, say a N cycle positive pulse:
    - set FRQ to 1
    - set PHS to 232 - N
    - set counter to NCO mode %00100 (PHS bit 31 = output)
    - waitcnt for longer pulses > 4 cycles (calculate beforehand)
    - stop the counter (CTR = 0) or reload PHS

    How it works: this sets the counter to output a very slow square wave of 2^32 cycles (about 54 seconds at 80 MHz), but more importantly starts the counter N cycles before it is about to transition from 1 to 0. There is lots of time after the transition to stop the counter (pseudo "one-shot") or restart it.

    If you want to send out back-to-back short pulses like this, then you have to use multiple synchronized cogs (waitcnt), as the counter setup takes at least 16 cycles per pulse.
Sign In or Register to comment.