libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
PWM2 Class Reference

Run a high speed pulse width modulation (PWM) class that can output up to two channels of duty cycled PWM at a single frequency. More...

#include <pwm2.h>

Public Member Functions

void Start (void)
 Start a PWM driver in a new cog. More...
 
void Stop (void)
 Stop the PWM driver (if running) More...
 
void SetPinX (const int pinX)
 Set a pin to PWM out on. More...
 
void SetPinY (const int pinY)
 Set a pin to PWM out on. More...
 
void SetDutyX (const int percent)
 Output a square wave with specified duty cycle. More...
 
void SetDutyY (const int percent)
 Output a square wave with specified duty cycle. More...
 
void SetFrequency (const int frequency)
 Set the frequency to output channel X and Y on. More...
 

Detailed Description

Run a high speed pulse width modulation (PWM) class that can output up to two channels of duty cycled PWM at a single frequency.

The two channels are channel X and channel Y.

Requires a cog to operate. No external hardware is required beyond whatever you are PWM'ing.

You can use this class to PWM H bridges, LEDs, audio, etc.

Todo:
(SRLM): figure out the maximum frequency (as a function of clock speed)

Copyright (c) 2013 Kenneth Bedolla (libpr.nosp@m.opel.nosp@m.ler@k.nosp@m.enne.nosp@m.thbed.nosp@m.olla.nosp@m..com)

Member Function Documentation

void PWM2::SetDutyX ( const int  percent)
inline

Output a square wave with specified duty cycle.

Parameters
percentThe duty [0..100] to PWM. 0 is off, 100 is full on.
void PWM2::SetDutyY ( const int  percent)
inline

Output a square wave with specified duty cycle.

You can change this during operation.

Parameters
percentThe duty [0..100] to PWM. 0 is off, 100 is full on.
void PWM2::SetFrequency ( const int  frequency)
inline

Set the frequency to output channel X and Y on.

Todo:
(SRLM): SetFrequency doesn't seem to actually change the frequency (at least once the cog is started...)
Parameters
frequencyThe frequency in Hz, [0..40000??]

Here is the call graph for this function:

void PWM2::SetPinX ( const int  pinX)
inline

Set a pin to PWM out on.

You can change this during operation.

Parameters
pinXThe I/O pin [0..31] to set the X channel on.
void PWM2::SetPinY ( const int  pinY)
inline

Set a pin to PWM out on.

You can change this during operation.

Parameters
pinYThe I/O pin [0..31] to set the Y channel on.
void PWM2::Start ( void  )
inline

Start a PWM driver in a new cog.

Here is the call graph for this function:

void PWM2::Stop ( void  )
inline

Stop the PWM driver (if running)

Here is the call graph for this function:


The documentation for this class was generated from the following file: