7 event counting – Panasonic MN103001G/F01K User Manual

Page 285

Advertising
background image

16-bit Timers

11-31

11.6.7

Event Counting

When using timer 10 as an event counter, make the settings according to the procedure described below.

This event counter generates a compare/capture A interrupt when it has counted the specified number of edges.
(Refer to Fig. 11-6-15.)

The compare/capture B register can be used as a compare register or as a capture register.

Note: For details on the settings, refer to section 11.6.1, "Compare Register Settings."

Procedure for initiating operation

(1) Set the compare/capture A register mode.

Set the TM10MDA register as follows:

TM10AO2,1,0 Don't care
TM10ACE

0: Capture operation disabled

TM10AEG

Don't care

TM10AM1,0

00: Compare register (single-buffer)

or
01: Compare register (double-buffer)

If the interrupt cycle will change while the counting operation is in progress, be certain
to set "double-buffer."

(2) Set the input edge for the TM10IOB pin.

Select either the rising edge or the falling edge at the TM10BEG of the TM10MDB register.

(3) Set the timer division ratio.

Set the division ratio in TM10CA.

A compare/capture A interrupt request is then generated when the specified edge is counted (value set
in TM10CA + 1) times on the TM10IOB pin.

(4) Set the operating mode.

Set the TM10MD register as described below:

TM10CK2,1,0 111:

Sets the TM10IOB pin input as the clock source.

TM10CAE

1:

Clears TM10BC when TM10CA matches TM10BC.

TM10ONE

0:

Disables one-shot operation.

TM10TGE

0:

Disables timer start by an external trigger.

TM10PM1,0

Don't care; This setting is ignored.

TM10PME

0:

Selects the normal waveform.

TM10LDE

0:

Normal operation.

TM10CNE

0:

Stops counting operation.

(5) Initialize the timer.

Set TM10LDE in the TM10MD register to "1" in order to initialize timer 10.

TM10BC is cleared, and the pin output is reset.
In addition, if TM10CA is set as a double-buffer compare register, the value in the buffer is loaded into

the compare register.

After initialization is completed, be certain to reset TM10LDE back to "0" in order to restore normal

operation mode.

(6) Set the I/O port.

Set the I/O port to "input pin."

Note:For details on the I/O port register settings, refer to chapter 15, "I/O Ports."

(7) Enable the timer counting operation.

The counting operation starts when the TM10CNE in the TM10MD register is set to "1".

Advertising