Shop OBEX P1 Docs P2 Docs Learn Events
propeller c clock speed — Parallax Forums

propeller c clock speed


I bought a propeller education kit some time ago. this was when spin was all there was. I had so many projects that years have passed and I never did master spin. I just bought a activity bot and am learning propeller c but I am unable to find how to set the propellers clock speed. if I remember right in spin you the default was 5mhz unless you specified a higher clock up to 80mhz.

there must be a way to do the same thing in c?

thanks

Comments

  • I believe that SimpleIDE sets the prop speed to 80MHz (crystal and PLL). In the Simple libraries (I think it's the propeller.h sub-library) there are functions that can be used to set the clock speed if something other than 80MHZ is needed.

    Tom
  • Can't you just call clkset and then set CLKFREQ to the new value, like you would in Spin?

    It never seemed strange to me to put clkfreq at location 0 in Spin (I learned Spin before C), but it just doesn't seem right to get the current clock frequency in C by dereferencing a NULL pointer.
  • The C program gets compiled leaving the clock speed and other hardware specific settings open.

    The loader will be told to which type of board you want to upload the code and while uploading will put in the board specific details like which crystal mode and speed is used and which multiplier and where to find a SD card (if available) and whatever else the configuration file for that board tells him.

    Search the folder of your propeller-gcc and then the subfolder with the loader's board descriptions (/opt/parallax/propeller-load on my systems, I use only C, not the IDE...).

    Digging through https://github.com/parallaxinc/propgcc/tree/master/loader may help too...

    And if I have written too much trash now, the propgcc authorities will correct me... ;-D
  • From propeller.h
    #define clkset (   mode, frequency ) 
    
    /*
    Set clock mode and frequency. 
    
    This macro is used to set the run-time clock mode and frequency. The clock mode and frequency are normally configured by the loader based on the user selected board type.
    
    Please see the Propeller Data Sheet for more clock information.
    Parameters
    mode: The 8 bit clock mode  
    frequency: The 32 bit clock frequency  
    Returns: This macro will not return a value. 
    */
    
    

  • sorry it took me so long to reply. I'm swamped at work.

    thanks for the info.



  • wait.. are you saying that the clk freq is automatically set to 80mhz? unless I use propeller.h and set the freq to some other value?
  • SimpleIDE selects it for you, based on the "Board" you select. Those are just in a text file somewhere and easy to add / configure. You can also just change it at runtime by setting the CLK, PLL, XINFRQ values like you can in Spin.
  • The SimpleIDE User Guide provides some information about the board configuration files. They are located in the SimpleIDE/propeller-gcc/propeller directory. You just need to determine where the SimpleIDE directory is on your particular system. You can then copy one of the existing board .cfg files to a new file, and edit the clock rate. You also need to add the .cfg file name to boards.txt. Your new board configuration file will then appear in the list of board types under Project Options in the Project View.

    It would be nice if board configuration files could be created and edited within SimpleIDE itself. That would be a nice future enhancement.
  • thanks guys.
Sign In or Register to comment.