System Clock Frequency forcing in Propeller C
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___
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
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);
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