CLKSET(), syntax?
![Tracy Allen](https://forums.parallax.com/uploads/userpics/712/nTZD6K4WNP6G3.png)
What is the proper syntax for CLKSET() in spin? It requires two parameters, and this snippet compiles:
But I am not sure, especially about the 2nd parameter, and in relation to RCfast and RCslow.![rolleyes.gif](http://forums.parallax.com/images/smilies/rolleyes.gif)
(Twiddle is just a test program for current drain at different frequencies.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
clkset(xtal1 + pll16x ,5_000_000) twiddle(5,20) clkset(xtal1 + pll4x ,5_000_000) twiddle(5,20) clkset(xtal1 + pll16x ,5_000_000) twiddle(5,20) clkset(xtal1 + pll1x ,5_000_000) twiddle(5,20) clkset(xtal1 ,5_000_000) twiddle(5,20) clkset(RCfast,12_000_000) twiddle(5,20) clkset(RCslow,20_000) twiddle(5,20)
But I am not sure, especially about the 2nd parameter, and in relation to RCfast and RCslow.
![rolleyes.gif](http://forums.parallax.com/images/smilies/rolleyes.gif)
(Twiddle is just a test program for current drain at different frequencies.)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Comments
'mode' is the 7-bit value which will be written to the global clock register in the HUB. This value is incompatible with the symbolic CONstants used to set up the initial clock mode (_CLKMODE = ...).
'freq' is the actual internal clock frequency that will be in effect.
Perhaps later we will harmonize these constants to be compatible with the 'mode' requirement. Well, on second thought, that·will not be·possible. This is because switching between clock modes is sometimes a process, where you must make the switch in two steps. For example, say you're running at 20KHz and you want to switch to 80MHz. You would first have to enable the crystal oscillator and PLL, but not switch to them immediately, because the crystal oscillator needs about 10ms to stabilize, worst case (the PLL takes only 10us, or so). So, you would have to wait for 10ms, and then make the final switch over to the PLL. This is covered in the last page(s) of the 'propellerguts.doc' file which was posted on this forum a few weeks ago.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
clkset($00, 12_000_000) ' RCfast, nominal clock frequency is 12mhz
clkset($01, 20_000) ' RCslow, nominal clock frequency is 20khz
clkset($6F, 80_000_000) ' pll16x with 5mhz xtal, 2000 ohms 36pf, actual clock frequency is 80mhz
Let's say I want the sequence to go from RCslow to pll16x. Do I need to do it in the following sequence:
Suppose that the task that needs to be performed at high speed does not depend on exact frequency. I just want it to wake up, perform a simple task as fast as possible and get back to sleep asap. Is there anything bad that will happen if I leave out the 10 millisecond warmup? It might be faster to switch to RCfast and back, but resonators can get up to speed pretty fast, and a response critical task might come first and then wait in software for a frequency critical task.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
May I suggest you add the propellerguts.pdf file to the download section, or did I just miss it?
-Parsko
http://forums.parallax.com/attachment.php?attachmentid=40588
http://forums.parallax.com/showthread.php?p=572669
Chip, how about this, to first switch to RCfast for response, while the xtal & pll warm up, then switch to them after the delay?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Chip Gracey
Parallax, Inc.