Professional Documents
Culture Documents
InitReloadCapture
start by enabling the clock to the timer (Wide Timer 1)
we want to use the full 32 bit count, so initialize the Interval Load
register to 0xffffffff (its default value)
To set the event to rising edge, we need to modify the TAEVENT bits
in GPTMCTL. Rising edges = 00, so we set the TAEVENT bits
Now Set up the port to do the capture (clock was enabled earlier)
start by setting the alternate function for Port C bit 6 (WT1CCP0)
StartReloadCapture
now kick the InputCaptureTimer off by enabling it and
enabling the timer to stall while stopped by the debugger
End of StartReloadCapture
StopReloadCapture
now stop the InputCaptureTimer by writing 0 to it
End of StopReloadCapture
ReloadCaptureResponse
start by clearing the source of the interrupt, the input capture event
InitReloadOneShot
start by enabling the clock to the timer (Wide Timer 1)
set timeout
StartReloadOneShot
now kick the timer off by enabling it and enabling the timer to
stall while stopped by the debugger
End of StartReloadOneShot
StopReloadOneShot
now stop timer by writing 0 to enable register
End of StopReloadOneShot
ReloadOneShotIntResponse
start by clearing the source of the interrupt
increment our counter so that we can tell this is running
clear accumulated noise on counts
OneShotTimer timing out means the no beacon pulses detected
post an event to GameMasterSM with event type as EV_EMITTER_MISSED
End of ReloadOneShotIntResponse
InitIRPWM
IR output is PE4 M1PWM2
start by enabling the clock to the PWM Module (PWM1)
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
now choose to map PWM to those pins, this is a mux value of 5 that we
want to use for specifying the function on bits 4
set the up/down count mode, enable the PWM generator and make
both generator updates locally synchronized to zero count
End of InitIRPWM