Need 2 PWM outputs with different frequency

Status
Not open for further replies.

hjchen

New Member
Hello all,
I'm using PIC16F1508 to generate two PWM outputs (200KHz and 20KHz) via PWM1 and PWM2 pins. Because, PR2 can not assign to PWM1 and PWM2 simultaneously, how can I solve it.
 
how about using pwm modual for one output then software pwm for the other? using another timer and interupt maybe???
 
Do you want to adjust either or both the PWM outputs?

If not:

Simply use one sub-routine that outputs 200kHz and every 10 loops of the sub-routine it outputs to the 20kHz pin.
 
Last edited:
Simply use one sub-routine that outputs 200kHz and every 10 loops of the sub-routine it outputs to the 20kHz pin.

That will just give a 20kHz output - not a PWM output.

I suggest the OP uses something like the Pic16F1829 as this can do two PWMs in hardware.

Mike.
 
Easiest way is to use HW PWM for 20kHz and SW PWM for 200Hz (**broken link removed**).

You could probably use the TMR2 and run the 200Hz from the 20kHz PWM (i.e. count TMR2 overflows for 200Hz).
 
I like to solve problems at the source. ie; why do you need 200kHz and 20kHz PWMs? If you give more info on what the PWMs are driving and how fast you need to change the PWN etc we can suggest a number of good solutions.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…