Using the HC12 Pulse Accumulator

The Pulse Accumulator measures events on Bit 7 of Port T

1.
Event count mode. Examples of use: Count number of people entering room. Count number of revolutions of a wheel in one second to determine speed (in RPS).
(a)
Enable PACTL (Set bit PAEN in the PACTL register)
(b)
Set mode to event count (Clear bit PAMOD in the PACTL register)
(c)
Choose edge with PEDGE bit of PACTL register:
PEDGE = 0 => count falling edges
PEDGE = 1 => count rising edges
(d)
Clear 16-bit PACNT register (if desired)
(e)
If desired, enable interrupt on any selected edge - set PAI bit of PACTL register
(f)
If desired, enable interrupt on PACNT overflow - set PAOVI bit of PACTL register
(g)
When desired, read PACNT register to determine how many events have occurred.
2.
Gated time accumulation mode - Example of use: Determine the length of a pulse
(a)
Enable timer (Set bit TEN in the TSCR register)
(b)
Enable PACTL (Set bit PAEN in the PACTL register)
(c)
Choose whether to count when input is high or input is low
PEDGE = 0 => count when input high
PEDGE = 1 => count when input low
(d)
Clear 16-bit PACNT register (if desired)
(e)
If desired, enable interrupt on selected edge - set PAI bit of PACTL register
(f)
If desired, enable interrupt on PACNT overflow - set PAOVI bit of PACTL register
(g)
When desired, read PACNT register to determine how clock edges have occurred while input is in active state.



 

1999-03-11