FlexProp P1 Clock Frequency "C"

How does one change the Clock Mode and Frequency for the P1 in FlexPropC.

The FlexProp help file says...
P1 Clock Frequency

In C code, the P1 clock frequency defaults to 80 MHz, assuming a 5 MHz crystal and xtal1 + pll16x clock mode. This is a common configuration. You may override it with the builtin clkset function, which works the same as the Spin clkset builtin.

Its been awhile since I have messed with spin but the propeller manual says....
clkset(%01101100, 4_000_000)           'Set to XTAL1 + PLL2x

I have tried multiple pieces of code but can't get anything to compile.


  • ShawnaShawna Posts: 497
    edited 2020-11-14 - 02:26:42
    I think I found it.
    #define clkset(a, b) _clkset(a, b)

    Seems it has to be placed after int main.
    int main(){  
    clkset(a, b)

    I was trying to set it before.
  • Something like this.
    #include <simpletools.h>
    int counts = 0;
    int Mode = 111;		//XTAL1 + PLL16X
    int MHZ = 80000000;
    int main(){
        clkset(Mode , MHZ);                      // Set system mode and clock.     
    	print("%c" , 16);			// Clear PST    
    	print("Count = %d\n", counts);
            counts = counts + 1;
  • yetiyeti Posts: 751
    edited 2020-11-14 - 10:05:27
    —▷ https://github.com/totalspectrum/spin2cpp/blob/master/doc/c.md#runtime-environment

    So you only need to set it if you don't want the default.
    This even applies to FlexSpin.
  • yeti wrote: »
    So you only need to set it if you don't want the default.
    This even applies to FlexSpin.
    Yeah, that's a good point.

    I know this but I am trying to overclock the prop and was having problems using the clkset(mode, frequency) function. I figured once I was able to get the code to compile I would be good but I am still having issues. I am hesitant to ask overclocking questions in this thread because I started a similar one 9 months ago for simpletools.

Sign In or Register to comment.