PIC1F1508 with four PWM outputs operating at different frequency?

Status
Not open for further replies.
See data sheet section 23.1.1
The period is common to all PWM modules, whereas the duty cycle is independently controlled.

Brian
 
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
Thanks, oh no, we need some to be slower than others, thats why i was hoping that one of the pwm streams can have like a software flip flop put with it to make it say half the frequency
 

If the frequencies are multiple integers as you said (2x, 4x, 8x) and if the output lowpass filter circuit is properly sized, at first sight there is no impediment to do that as long as the signal to be generated has been oversampled during its capture or computation.
 

Provided your PWM frequency isn't too high you can generate your own PWM waveform in software like this:

1. use one of the hardware timers to generate the lowest base PWM frequency.
2. Use another hardware timer at higher speed to generate the delays between PWM 'steps' (resolution).
3. Set the output port bits according to the output of stage 1
4. Reset the bits according to (required delay * 'steps') from stage 2.

By adjusting the required delay value in stage 4 you change the pulse width. Replicating the calculation in stage 4 for different pins gives you the extra outputs you need.

I do it in a device that generates 11 individual PWM outputs from a now rather dated 16F877A using that method but I only use a PWM frequency of about 100Hz which may be slower than you need. In principle the method works as fast as your software will allow and it should be possible to reach several KHz without any difficulty.

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…