//Initializes PWM for Channel 0 and takes in the
parameters to determine PWM
//Output Polarity and PWM Clock Select (just prescale or prescale & postscale.)
initPWM0: parameters =
Polarity and PostScaleOption
Enable
PWM0 with PWME
Map PWM0
to Port T with MODRR
If
Polarity is initially hi
Set
PWMPOL of PWM0 hi
Else
Polarity is initially low
Set
PWMPOL of PWM0 lo
If want PostScaleOption
Set
PWMCLK hi
Else
Set
PWMCLK low = prescaled clock only
Set duty
cycle of PWM0 initially = 0 so motors don’t start
setPWM0Period:
parameters = desired # of clock counts in 1 period
PWMPER0 =
period
setPWM0DutyCycle:
parameter = number of clock counts for active part of duty cycle
PWMDTY0 = dutyCycle
//Initializes PWM for Channel 1 and takes in the
parameters to determine PWM
//Output Polarity and PWM Clock Select (just prescale or prescale & postscale.)
initPWM1: parameters =
Polarity and PostScaleOption
Enable
PWM1 with PWME
Map PWM1
to Port T with MODRR
If
Polarity is initially hi
Set
PWMPOL of PWM1 hi
Else
Polarity is initially low
Set
PWMPOL of PWM1 lo
If want PostScaleOption
Set
PWMCLK hi
Else
Set
PWMCLK low = prescaled clock only
Set duty
cycle of PWM1 initially = 0 so motors don’t start
setPWM1Period:
parameters = desired # of clock counts in 1 period
PWMPER1 =
period;
setPWM1DutyCycle:
parameter = number of clock counts for active part of duty cycle
PWMDTY0 = dutyCycle;