Need more than 2 pwm

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
WalkOver
Posts: 65
Joined: Fri Nov 23, 2007 11:24 pm

Need more than 2 pwm

Post by WalkOver »

Hello everyone!

I need for a project more than 2 pwm.

How can I create a third with Flowcode using an other digital output?

Thank you in advance ;-)

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Post by Sean »

The technique used to create extra PWM channels depends on the frequency and accuracy required.
One of the best ways to generate accurate timing intervals is the Timer 0 interrupt.
Timer 0 continuously counts from 0 to 255 and can generate an interrupt when it overflows back from 255 to 0. The clock source for Timer 0 is controlled by a prescaler that can be programmed from the Flowcode interrupt component to divide the master clock frequency by a range of values.
A time interval can be set by preloading the Timer 0 count register with 255 - interval (based on the prescaled timer clock frequency).
The interrupt service macro must alternaly preload the appropriate MARK and SPACE values into the Timer 0 count register (SPACE = 255 - MARK), and control the logic level of the selected output.
Special precautions might be required if the MARK value is close to 0 or 255.

Post Reply