Panasonic F77G Timer 1 mode register to 0 to stop timer 0, TM1MD x3F55 Timer 1 counting Bp3

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 255
Image 255

Chapter 6 8-bit Timers

6-10-2 Setup Example

„Cascade Connection Timer Setup Example (Timer 0 + Timer 1)

Setting example of timer function that an interrupt is constantly generated by cascade connection of timer 0 and timer 1, as a 16-bit timer is shown. An interrupt is generated in every 2500 cycles (1 ms) by selecting source clock to fs/4 (fosc=20 MHz at operation).

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", the TM1EN flag of the

bp3

:TM0EN

= 0

timer 1 mode register to "0" to stop timer 0 and

TM1MD (x'3F55')

 

timer 1 counting.

bp3

:TM1EN

= 0

 

(2) Select the normal operation lower

(2) Set both of the TM0PWM flag and TM0MOD

timer.

 

 

flag of the TM0MD register to "0" to select the

TM0MD (x'3F54')

 

normal operation of timer 0.

bp4

:TM0PWM

= 0

 

bp5

:TM0MOD

= 0

 

(3) Set the cascade connection.

(3) Set the TM1CAS flag of the TM1MD register to

TM1MD (x'3F55')

 

"1" to connect timer 1 and timer 0 in cascade

bp4

:TM1CAS

= 1

connection.

(4) Select the count clock source.

(4) Set the clock source to prescaler output by

TM0MD (x'3F54')

 

the TM0CK2-0 flag of the TM0MD register.

bp2-0

:TM0CK2-0 = 001

 

(5) Select the prescaler output and

(5) Set the prescaler output to fs/4 by the

enable 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')

 

prescaler counting.

bp0

:PSCEN

= 1

 

(6) Set the interrupt generation cycle

(6) Set the timer 1 compare register + timer 0

TMnOC(x'3F53', x'3F52')=x'09C3'

compare register (TM1OC + TM0OC) to the

 

 

 

interrupt generation cycle (x'09C3' : 2500

 

 

 

cycles - 1).

 

 

 

At that time, timer 1 binary counter + timer 0

 

 

 

binary counter (TM1BC + TM0BC) are

 

 

 

initialized to x'0000'.

 

 

 

 

Cascade Connection VI - 41

Page 255
Image 255
Panasonic F77G, MN101C77C Timer 1 mode register to 0 to stop timer 0, TM1MD x3F55 Timer 1 counting Bp3, Connection