3-2 setup example – Panasonic MN101C77C User Manual

Page 273

Advertising
background image

VII - 13

Chapter 7 16-bit Timer

16-bit Timer Count

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.

(1) Set the TM7EN flag of the timer 7 mode

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

(2) Set the TM7BCR flag of the timer 7 mode

register 2 (TM7MD2) to "1" to select the
compare match as a binary counter clear
source.

(3) Select fosc as a clock source by the TM7CK1-

0 flag of the TM7MD1 register. Also select 1/2
fosc as a count clock source by TM7PS1-0
flag.

(4) Set the interrupt generation cycle to the timer 7

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 by the TM7LV1-0 flag of

the timer 7 interrupt control register (TM7ICR).
If the interrupt request flag may be already set,
clear the request flag.

(6) Set the TM7IE flag of the TM7ICR register to

"1" to enable the interrupt.

Setup Procedure

(1) Stop the counter.

TM7MD1 (x'3F78')

bp4

: TM7EN

= 0

(2) Select the timer clear source.

TM7MD2 (x'3F79')

bp5

: TM7BCR = 1

(3) Select the count clock source.

TM7MD1 (x'3F78')

bp1-0

: TM7CK1-0 = 00

bp3-2

: TM7PS1-0 = 01

(4) Set the interrupt generation cycle.

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

(5) Set the interrupt level.

TM7ICR (x'3FF1')

bp7-6

: TM7LV1-0 = 10

(6) Enable the interrupt.

TM7ICR (x'3FF1')

bp1

: TM7IE

= 1

Description

[

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

Advertising
This manual is related to the following products: