Chapter 7 16-bit Timer

7-3-2 Setup Example

„Timer Operation Setup Example (Timer 7)

Timer 7 generates an interrupt constantly for timer function. Fosc/2 (fosc=20 MHz) is selected as a clock source to generate an interrupt every 1000 cycles (100 µs).

An example setup procedure, with a description of each step is shown below.

 

Setup Procedure

 

 

 

Description

 

 

 

 

 

(1)

Stop the counter.

 

(1)

Set the TM7EN flag of the timer 7 mode

 

TM7MD1 (x'3F78')

 

 

register 1 (TM7MD1) to "0" to stop timer 7

 

bp4

: TM7EN

= 0

 

counting.

(2)

Select the timer clear source.

(2)

Set the TM7BCR flag of the timer 7 mode

 

TM7MD2 (x'3F79')

 

 

register 2 (TM7MD2) to "1" to select the

 

bp5

: TM7BCR

= 1

 

compare match as a binary counter clear

 

 

 

 

 

source.

 

(3)

Select the count clock source.

(3)

Select fosc as a clock source by the TM7CK1-

 

TM7MD1 (x'3F78')

 

 

0 flag of the TM7MD1 register. Also select 1/2

 

bp1-0

: TM7CK1-0 = 00

 

fosc as a count clock source by TM7PS1-0

 

bp3-2

: TM7PS1-0 = 01

 

flag.

 

(4)

Set the interrupt generation cycle.

(4)

Set the interrupt generation cycle to the timer 7

 

TM7PR1 (x'3F75', x'3F74')=x'03E7

 

preset register 1 (TM7PR1). The cycle is 1000.

 

 

 

 

 

The set value should be 1000-1=999(x'03E7').

 

 

 

 

 

At that time, the same value is loaded to the

 

 

 

 

 

timer 7 compare register 1 (TM7OC1), and the

 

 

 

 

 

timer 7 binary counter (TM7BC) is initialized to

 

 

 

 

 

x'0000'.

 

(5)

Set the interrupt level.

 

(5)

Set the interrupt level by the TM7LV1-0 flag of

 

TM7ICR (x'3FF1')

 

 

the timer 7 interrupt control register (TM7ICR).

 

bp7-6

: TM7LV1-0 = 10

 

If the interrupt request flag may be already set,

 

 

 

 

 

clear the request flag.

 

 

 

 

 

[

Chapter 3 3-1-4. Interrupt Flag Setup ]

(6)

Enable the interrupt.

 

(6)

Set the TM7IE flag of the TM7ICR register to

 

TM7ICR (x'3FF1')

 

 

"1" to enable the interrupt.

 

bp1

: TM7IE

= 1

 

 

 

 

 

 

 

 

 

 

16-bit Timer Count VII - 13

Page 273
Image 273
Panasonic F77G, MN101C77C user manual TM7EN, TM7BCR, Compare match as a binary counter clear, TM7IE