Problem with multi clock speeds
RoboTuna
Posts: 25
I am new to the spin language and I have only worked with BS2 for a short time. I have the Compass Module 3-Axis HMC5883 it runs a clock speed of 80Mhz and all the other sensors I am using run at 5Mhz I have tried changing the clock speed on the compass and it does not function correctly. Any help on this would be great.
Comments
Next, there is the clock speed of communication lines. The HMC5883 uses I2C, so that goes up to 400KHz. That is completely independent of the Propeller clock, and that is set by the I2C object that you use.
If you post your code we may be able to be more helpful.
I2C requires pull-up resistors (usually on both data and clock). It looks like you're using P0 and P1 for you compass. Do you have pull-up resistors on those lines?
There are probably already pull-up resistors on P28 and P29 (as originally shown in the object). If you switch back to those pins, you might have better luck.
Which Propeller board are you using?
The PropBOE doesn't give you access to the I2C bus. You'll need pull-up resistors on pins you use to communicate with the compass.
As SLRM said above, I'm pretty sure you don't have the way clock speeds are used correct.
If you post your GPS code, we can take a look at it. I'm just about positive the clock speed issue isn't a problem.
That code also uses an 80MHz clock speed. The 5MHz is the crystal frequency. There is more than one way of defining clock speed and either way is fine.
So is this what i am not understanding. this is the 80Mhz for the clock
Both objects have this line:
IThe above code basically is telling the Propeller you're using a relatively slow external crystal ("xtal1") and you want the to multiply the crystal frequency by 16 ("pll16x). Page 68 of the Propeller Manual give more information about the above code.
The Propeller also needs to know the frequency of the crystal so it knows how many clock cycles to use per bit when transmitting or receiving a serial signal (as well as other timing needs). There are two ways of telling the Propeller what crystal you're using. One is to state the crystal frequency with "_xinfreq" as in your GPS object.
The other way is to tell the Prop the final clock frequency and let it figure out what the crystal frequency is based on the PLL multiplier. The compass object uses this approach.
When you combine the objects into one program you'll just use one of these techniques, it doesn't matter which one but only use one. The clock setting of the parent object is given priority over any other objects' clock settings.
You want to make sure you only use the above clock settings in Propeller boards with 5MHz crystals. There are a few Propeller boards with 10MHz crystals. Some people also use 6.25MHz crystals to overclock the Prop to 100MHz. Many(most?) crystals can used with multiple PLL multipliers (but only one at a time) to give a variety of possible clock frequencies (slower clock speeds use less power).
I've tried to list some aids in learning to program the Propeller in post #3 of my index. If you check out some of my projects listed in post #2, you'll see why I like the Propeller so much.
You're very welcome.