Shop OBEX P1 Docs P2 Docs Learn Events
Problem with multi clock speeds — Parallax Forums

Problem with multi clock speeds

RoboTunaRoboTuna Posts: 25
edited 2012-12-10 23:56 in Propeller 1
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

  • SRLMSRLM Posts: 5,045
    edited 2012-12-10 19:24
    I think you misunderstand the various clocks that are in the system. The Propeller, for most users, will run at 80MHz. This is with an XIN of 5MHz and PLL of 16x. You don't need to change it.

    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.
  • RoboTunaRoboTuna Posts: 25
    edited 2012-12-10 19:37
    that is the code for the compass i do not have any code using it with anything else just yet.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-10 20:02
    RoboTuna wrote: »
    that is the code for the compass i do not have any code using it with anything else just yet.

    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?
  • RoboTunaRoboTuna Posts: 25
    edited 2012-12-10 20:08
    Prop Board of Education. I am not having any problem receiving data i can get the Degrees with that code and those pins. I am just not understanding two different clock speeds it my GPS uses 5MHz
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-10 20:43
    RoboTuna wrote: »
    Prop Board of Education. I am not having any problem receiving data i can get the Degrees with that code and those pins. I am just not understanding two different clock speeds it my GPS uses 5MHz

    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.
  • RoboTunaRoboTuna Posts: 25
    edited 2012-12-10 21:06
    Okay that is the GPS code I will be using.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-10 21:09
    RoboTuna wrote: »
    Okay that is the GPS code I will be using.

    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.
  • RoboTunaRoboTuna Posts: 25
    edited 2012-12-10 21:16
    xtal1 + pll16x

    So is this what i am not understanding. this is the 80Mhz for the clock
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-10 23:26
    Both objects you posted use an 80MHz clock. They just use different ways of defining the clock speed.

    Both objects have this line:
    _clkmode      = xtal1 + pll16x
    

    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.
    _xinfreq        = 5_000_000
    

    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.
    _clkfreq      = 80_000_000
    

    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.
  • RoboTunaRoboTuna Posts: 25
    edited 2012-12-10 23:32
    Thank you very much i was able to combine the two programs so now i can view position and direction while stationary. thanks for your help.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-10 23:56
    RoboTuna wrote: »
    thanks for your help.

    You're very welcome.
Sign In or Register to comment.