Shop OBEX P1 Docs P2 Docs Learn Events
clock frequency — Parallax Forums

clock frequency

Hello, I was looking at a sensor example code (https://www.parallax.com/downloads/3-axis-compass-module-propeller-code) and I noticed that the clock setting is as follow

_clkmode = xtal1 + pll16x
_clkfreq = 80_000_000

Q1. I thought _clkfreq is for the external clock frequency, for the most of props, it's 5M Hz.. ? But, how is it possible to use 80MHz? If I lower it to 5MHz, the sampling rate would be decreased as well?

Q2. Why is external clock is used?

Q3. Also, it says
Serial Clock - I²C Master/Slave Clock (Clock 160Hz Default)
What is 160Hz about? Is it just sensor specification or is it somehow related to 80MHz and affecting sampling rate?

I'd appreciate if someone can help me out.

Thank you.

Comments

  • 1. Regarding the clock settings, 5mhz * 16 =80mhz. That's using the internal pll to multiply the clock.
    2. Externally clocking is usually used to increase operating frequency. The internal RC oscillators can vary in frequency so good async serial comms really needs the external clock.

    3. I'd have to look at the code to see but I'm guessing the sensor uses 160 hz i2c clock.

    As far as changing the clock frequency, sampling rate should not be affected as long as there's enough clocks for the code to complete. I'm guessing it might work but if you have a serial object you might need to lower baud. That kind of clock frequency drop is likely to break the code although I could be wrong. Maybe 40 mhz? I'd try changing the pll mode and see what happens.
    _clkmode = xtal1 + pll8x ' 40 mhz
    
    _clkmode = xtal1 + pll4x ' 20 mhz
    
    _clkmode = xtal1 + pll2x ' 10 mhz
    

    I have one of these sensors laying around, I might hook it up in the next couple days to see.

  • hylee101001hylee101001 Posts: 48
    edited 2016-05-21 16:15
    Thanks. But I'm still a little confused.
    5mhz * 16 =80mhz

    Q1. Here, 5MHz is the oscillator crystal frequency, if I'm right. And what's the 16 for? Also, if the oscillator's frequency is defined as
    _clkfreq = 80_000_000
    
    Wouldn't it be 8Mhz * 16 = 128MHz?

    Q2. Also, what is the pll? - I looked up it's a phase locked loop. I didn't fully understand but, in propeller, it seems it synchronizes the cogs somehow? But I'm still not getting why there are multiple PLLs.
  • See _XINFREQ.
  • SeairthSeairth Posts: 2,474
    edited 2016-05-21 16:32
    Q2. Also, what is the pll? - I looked up it's a phase locked loop. I didn't fully understand but, in propeller, it seems it synchronizes the cogs somehow? But I'm still not getting why there are multiple PLLs.

    Think of the PLL as a frequency multiplier circuit. The entire Propeller uses only one clock source at a time. When you specify XTAL1+PLL16 as the clock source, the frequency of the external crystal is fed into the 16x PLL. The output of the selected PLL is then fed through the rest of the chip. When the literature talks about synchronization, it's the PLL synchronizing to the source frequency (XTAL1, in this case).
  • Oh. Thanks.

    So, for example,

    _clkmode = xtal1 + pll16x
    _clkfreq = 80_000_000

    is the same thing as

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


  • Oh. Thanks.

    So, for example,

    _clkmode = xtal1 + pll16x
    _clkfreq = 80_000_000

    is the same thing as

    _clkmode = xtal1 + pll16x
    _xinfreq = 5_000_000


    That is correct.

Sign In or Register to comment.