4 starting by an external trigger – Panasonic MN103001G/F01K User Manual

Page 278

Advertising
background image

16-bit Timers

11-24

11.6.4

Starting by an External Trigger

Timer 10 can be started up by input on the TM10IOB pin. Fig. 11-6-8 illustrates the startup operation.

The compare/capture A and B registers can be used as compare registers or as capture registers.

Procedure for initiating operation

(1) Select the input edge on which timer 10 is to start.

Select the input edge through TM10BEG in the TM10MDB register.

The starting edge is the opposite of the normal setting.

TM10BEG = 0

Start when falling edge is input

TM10BEG = 1

Start when rising edge is input

(2) Set the operating mode.

Set the TM10MD register as described below:

TM10CK2,1,0

Don't care; select any clock source.

TM10CAE

Don't care; "1" when setting one-shot operation and the interrupt cycle.

TM10ONE

Don't care; "1" for one-shot operation.

TM10TGE

0:

This 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.

When using 1/8IOCLK or 1/32IOCLK as the clock source, set TMPSCNE in the TMPSCNT register to

"1" to enable prescaler operation before enabling the counting operation for timer 10.

(3) 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 the compare/capture register 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.

(4) Set the I/O port.

Set TM10IOB pin to "input pin."

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

(5) Enable timer startup by an external trigger.

Set TM10TGE in the TM10MD register to "1".

Once the specified edge is input to the TM10IOB pin, timer 10 starts up. (The TM10CNE flag in the TM10MD
register is set by the hardware.)

Advertising