Professional Documents
Culture Documents
LoadBall
put latch servo motor into LoadBall posiotn by setting the LoadPWMLat to
it
ChargeBall
put power servo motor to ChargeBall position by setting ChargePWMPow to
it
FireBall
put latch servo motor to FireBall position by setting FirePWM to it
ResetBall
put power servo motor to ResetBall position by setting ResetPWMPow to it
InitServo
PB4(M0PWM2) is used to generate PWM (up-down counting)
start by enabling the clock to the PWM Module (PWM0)
make sure that the PWM module clock has gotten going
Set the PWM period. Since we are counting both up & down, we initialize
the load register to 1/2 the desired total period. We will also program
the match compare registers to 1/2 the desired high time
Set the initial Duty cycle on A to 50% by programming the compare value
to 1/2 the period to count up (or down). Technically, the value to
program
should be Period/2 - DesiredHighTime/2, but since the desired high time
is 1/2
the period, we can skip the subtract
init servo to have 50% duty cycle, possibly need to tune
now choose to map PWM to those pins, this is a mux value of 4 that we
want to use for specifying the function on bit4 and bit5
set the up/down count mode, enable the PWM generator and make
both generator updates locally synchronized to zero count
End of InitServo