Can the clock frequency change automatically?
huynh
Posts: 16
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,
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
"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
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))
]
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