Shop OBEX P1 Docs P2 Docs Learn Events
System Clock Frequency forcing in Propeller C — Parallax Forums

System Clock Frequency forcing in Propeller C

dmaruccidmarucci Posts: 3
edited 2014-09-15 11:39 in Learn with BlocklyProp
Hi,
Dan here in SoCal. I've been looking a little bit, and I've found the corresponding function in SPIN, but how do you set the system clock frequency in propeller C?
I've got a Propeller Activity Board and I'm trying to go through the Bo-Bot training with my daughter. I want to teach her how to drive the servos with PWM, etc, but I don't want to use the already-written functions. I need to understand how to set the system clock to 80 mhz so I can get the pause() function to something finer than 1 ms, as I need to send a 1.5 ms pulse to hold the servo still. I could just make the assumtion that is already at 80 mhz and redfine the clock ticks, but how do I force it to a specific frequency?

Thanks for the help
Dan___

Comments

  • edited 2014-09-15 11:03
    Yeah, we've been going with 80 MHz by default. I'll reply on setting clock freq in the next post.

    pulse_out was designed to keep a signal high for a certain number of microseconds.

    If you prefer to use high-pause-low-pause, you can set the number of microseconds pause uses with set_pause_dt(CLKFREQ/1000000); More info in Help -> Simple Library Reference -> simpletools.h.

    Another approach might be to use the predefined us variable in simpletools.

    high(pin);
    waitcnt(CNT + 1500*us);
    low(pin);
    waitcnt(CNT + 20000000*us);
  • edited 2014-09-15 11:39
    The simpletools library includes propeller.h, which has a clkset function for setting the mode and frequency. If you have simpleIDE 0.9.64 or newer, use Help -> Simple Library Reference, and then follow the propeller.h link. Earlier versions can look here https://sites.google.com/site/propellergcc/documentation/libraries/propeller-h-library#TOC-clkset (which can be navigated to through Help -> PropGCC reference. That 8-bit value in the first parameter is documented in the Propeller datasheet https://sites.google.com/site/propellergcc/documentation/propeller-datasheet.

    Although I haven't tested this, it seems like you should be able to test the clock frequency with print("CLKFREQ = %d\n", CLKFREQ);

    Andy
Sign In or Register to comment.