Shop OBEX P1 Docs P2 Docs Learn Events
Can the clock frequency change automatically? — Parallax Forums

Can the clock frequency change automatically?

huynhhuynh Posts: 16
edited 2010-05-17 10:57 in Propeller 1
Dear all users,

It's my honor to have your opinion in an issue that involved with the clock frequency of Prostick USB.

I use an Prostick USB to receive data from some sensors, including the Digital magnetic compass and the rotational speed sensor. the clock setup is "
_CLKMODE = XTAL1 + PLL16X, 80 Mhz clock
_XINFREQ = 5_000_000;

As I use the function "byte[noparse][[/noparse]Stringptr][noparse][[/noparse]index++] := rx" the clock frequency looks quite different. By checking the following output:

out := (100_000_000/(clkfreq/1_000_000) + 1), (note: it just a function consisted of clkfreq/1_000_000)

i found that:
+ without the code of "byte[noparse][[/noparse]Stringptr][noparse][[/noparse]index++] := rx", the value of "out" is 12500001, so the clkfreq can be calculated as 80Mhz
+ as the code of "byte[noparse][[/noparse]Stringptr][noparse][[/noparse]index++] := rx" is included, the value of "out " is 724638, hence the corresponding clkfreq is 138Mhz

is it correct?

I do not have much experience about this issue. I am wondering whether there is a conflict as using the function of "byte[noparse][[/noparse]Stringptr][noparse][[/noparse]index++] := rx" or not.

Thank for any suggestion.

thien,

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2010-05-17 07:35
    no clock freq will not change without you explicitly changing it. Your symptoms are memory corruption. Check stringptr and index. If you post the rest of the code we can look and see if we can see the problem.
  • huynhhuynh Posts: 16
    edited 2010-05-17 09:11
    I found some information in the manual in page 63,64. it is said that:

    "CLKFREQ vs. _CLKFREQ
    CLKFREQ is related to, but not the same as, _CLKFREQ. CLKFREQ is command that returns the current System Clock frequency whereas _CLKFREQ is an application-defined constant that contains the application’s System Clock frequency at startup. In other words, CLKFREQ is the current clock frequency and _CLKFREQ is the original clock frequency; they both may happen to be the same value but they certainly can be different."

    It indicates that the CLKFREQ return the current clock frequency, which can differs from the origin value. But I still do not understand why it can be 138Mhz, while the maximum freq is 80Mhz.



    Here is the code that I use to receive data from digital magnetic compass


    pub DMCoutput | index

    repeat while RxDMC <> "$"
    RxDMC := DMC.rxcheck

    index~

    repeat while ( RxDMC <> "*" )
    RxDMC := DMC.rx

    byte[noparse][[/noparse]stringptr][noparse][[/noparse]index++] := RxDMC


    byte[noparse][[/noparse]stringptr][noparse][[/noparse]--index]~
    ]


    it is the subprogram in the main code
  • kuronekokuroneko Posts: 3,623
    edited 2010-05-17 09:17
    So what's the value of stringptr? It really helps when you show as all the code. Otherwise we keep guessing ...
  • huynhhuynh Posts: 16
    edited 2010-05-17 09:37
    Here the whole code. If you do not run the line of
    byte[noparse][[/noparse]stringptr][noparse][[/noparse]index++] := RxDMC and byte[noparse][[/noparse]stringptr][noparse][[/noparse]--index]~ , you will get the clkfreq of 80Mhz, but as you run them, you we get 138Mhz for the clkfreq. Is it possible? I think there was something wrong


    [noparse][[/noparse]

    CON

    _CLKMODE = XTAL1 + PLL16X ' 80 Mhz clock
    '_XINFREQ = 5_000_000
    _CLKFREQ = 80_000_000

    'serial port to PC
    PortRx = 26
    PortTx = 27

    ' compass input pin

    DMCTx = 22
    DMCRx = 25



    OBJ

    PortCom : "FullDuplexSerialPlus"

    DMC : "fullDuplexSerialPlusDMC"


    VAR

    'var DMC
    byte bufferDMC[noparse][[/noparse]25]
    long RxDMC
    long stringptr
    long ck




    PUB Start


    PortCom.start(PortRx, PortTx,0,115200)
    DMC.start(DMCRx, DMCTx, 0, 115200)

    repeat
    Main


    PUB Main |index


    repeat while RxDMC <> "$"
    RxDMC := DMC.rxcheck

    index~

    repeat while ( RxDMC <> "*")
    RxDMC := DMC.rx
    byte[noparse][[/noparse]stringptr][noparse][[/noparse]index++] := RxDMC

    byte[noparse][[/noparse]stringptr][noparse][[/noparse]--index]~


    ck := clkfreq

    portcom.str(string(13))
    portcom.str(stringptr)

    portcom.str(string(","))
    portcom.dec(ck)

    PortCom.str(string(10))


    ]
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-05-17 10:57
    And now guess what the value of stringptr is when you run that code?

    It's initialized to 0 and never set to an appropriate address. Guess what you want to do is:

    stringptr := @bufferDMC

    In your case you overwrite the first 16 bytes of RAM which have·a sepecial purpose including the variable CLKFREQ.


    Post Edited (MagIO2) : 5/17/2010 11:12:01 AM GMT
Sign In or Register to comment.