This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Hardware PWM - vary the frequency

I'm using a Philips P89C668 at 16MHz in 6-clock mode. I've got a piezo (with internal driver) on P1.3 (CEX0). I'd like to switch to a speaker and output PWM to get different tones. However, I can't find any good examples on how to vary the period (frequency). I've read the Intel PCA cookbook and their one example shows how to set it at the maximum frequency, but not how to vary it or how to use other PCA sources for PWM. I don't need to vary duty cycle. Here's the PCA init:

CMOD = 0x02;    // OSC/2 (6-clk mode)
CCAPM0 = 0x42;  // Mod0 in 8-bit PWM
CCAP0H = 0x80;  // set 50% duty cycle
CCAP0L = 0x00;  // set 50% duty cycle
CH = 0x00;
CL = 0x00;
CR = 1;         // turn it on

There don't appear to be any prescalers involved, so then am I stuck with a fixed output frequency? Would it help to change the PCA source to Timer0? If so, what other registers are involved and in what ways? The P89C668 datasheet is light on the details. Any help would be appreciated...

0