clock frequency
hylee101001
Posts: 48
in Propeller 1
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
I'd appreciate if someone can help me out.
Thank you.
_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
What is 160Hz about? Is it just sensor specification or is it somehow related to 80MHz and affecting sampling rate?Serial Clock - I²C Master/Slave Clock (Clock 160Hz Default)
I'd appreciate if someone can help me out.
Thank you.
Comments
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.
I have one of these sensors laying around, I might hook it up in the next couple days to see.
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 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.
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).
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.