Panasonic F77G, MN101C77C user manual TM0EN, TM0PWM, TM0MOD

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 231
Image 231

Chapter 6 8-bit Timers

6-3-2 Setup Example

„Timer Operation Setup Example (Timers 0, 1, 4 and 5)

Timer function can be set by using timer 0 that generates the constant interrupt. By selecting fs/4 (at fosc

=20 MHz) as a clock source, interrupt is generated every 250 clock 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 TM0EN flag of the timer 0 mode

 

TM0MD (x'3F54')

 

 

register (TM0MD) to "0" to stop the counting of

 

bp3

:TM0EN

= 0

 

timer 0.

(2)

Select the normal timer operation.

(2)

Set the TM0PWM flag and TM0MOD flag of

 

TM0MD (x'3F54')

 

 

the TM0MD register to "0" to select the normal

 

bp4

:TM0PWM

= 0

 

timer operation.

 

bp5

:TM0MOD

= 0

 

 

 

(3)

Select the count clock source.

(3)

Select the prescaler output to the clock source

 

TM0MD (x'3F54')

 

 

by the TM0CK2-0 flag of the TM0MD register.

 

bp2-0

:TM0CK2-0 = 001

 

 

 

(4)

Select the prescaler output and

(4)

Select fs/4 to the prescaler output by the

 

enable the counting.

 

 

TM0PSC1-0, TM0BAS flag of the timer 0

 

CK0MD (x'3F56')

 

 

prescaler selection register (CK0MD).

 

bp2-1

:TM0PSC1-0 = 01

 

Also, set the PSCEN flag of the prescaler

 

bp0

:TM0BAS

= 1

 

control register (PSCMD) to "1" to enable the

 

PSCMD (x'3F6F')

 

 

counting of the prescaler.

 

bp0

:PSCEN

= 1

 

 

 

(5)

Set the cycle of the interrupt

(5)

Set the value of the interrupt generation cycle

 

generation.

 

 

 

to the timer 0 compare register (TM0OC). The

 

TM0OC (x'3F52') = x'F9'

 

cycle is 250, so that the setting value is set to

 

 

 

 

 

249 (x'F9').

 

 

 

 

 

At that time, the timer 0 binary counter

 

 

 

 

 

(TM0BC) is initialized to x'00'.

(6)

Set the interrupt level.

 

(6)

Set the interrupt level by the TM0LV1-0 flag of

 

TM0ICR (x'3FE9')

 

 

the timer 0 interrupt control register (TM0ICR).

 

bp7-6

:TM0LV1-0

= 10

 

If the interrupt request flag may be already set,

 

 

 

 

 

clear the request flag.

 

 

 

 

 

[

Chapter 3 3-1-4. Interrupt flag setting ]

 

 

 

 

 

 

 

8-bit Timer Count VI - 17

Page 231
Image 231
Panasonic F77G, MN101C77C user manual TM0EN, TM0PWM, TM0MOD