clkset Question
smthrll
Posts: 4
Wondering if somebody could show me what I'm missing on the 'clkset' function.
My goal was to flash an LED at 5MHz crystal speed, and then increase the speed to 80MHz with the above code, and measure the difference on an oscilloscope. There seems to be no change - obviously missing something. The length of a high pulse remains ~ 12us with no difference.
[I]#include "simpletools.h" [/I][I]int main()[/I] [I]{[/I] [I] clkset(0b01101111,80000000);[/I] //xtal1 + 16pll [I] while(1)[/I] [I] {[/I] [I] high(15); [/I] [I] low(15);[/I] [I] } [/I] [I]}[/I]
My goal was to flash an LED at 5MHz crystal speed, and then increase the speed to 80MHz with the above code, and measure the difference on an oscilloscope. There seems to be no change - obviously missing something. The length of a high pulse remains ~ 12us with no difference.
Comments
If you want to blink the LED at 80MHz, you will need to use a counter.
The fastest you can blink an LED with an instruction loop is 10MHz (with an 80MHz system clock).
Yes.
Actually, simple/small code can be re-written to be faster even in CMM mode, but just for generating a square wave (toggling a pin) using the counters is the best solution.
This program toggles P15 at about 2.5MHz in CMM or LMM memory models. Fcache makes a small function run inside the COG. This can be even faster using in-line ASM.