Panasonic MN101C77C P1DIR x3F31 Control register P1DIR to 1 for the output Bp0, PWM operation

Models: F77G MN101C77C

1 544
Download 544 pages 59.61 Kb
Page 242
Image 242

Chapter 6 8-bit Timers

6-6-2 Setup Example

„PWM Output Setup Example (Timers 0, 4 and 5)

The 1/4 duty cycle PWM output waveform is output from the TM0IO output pin at 128 Hz by using timer 0 (at fx=32.768 kHz). Cycle period of PWM output waveform is decided by the overflow of the binary counter. "H" period of the PWM output waveform is decided by the setting value of the compare register. An example setup procedure, with a description of each step is shown below.

TM0IO output

128 Hz

Figure 6-6-4 Output Waveform of TM0IO Output Pin

 

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 timer 0

 

bp3

:TM0EN

= 0

 

counting.

(2)

Set the special function pin to

(2)

Set the P1OMD0 flag of the port 1 output mode

 

the output mode.

 

 

register (P1OMD) to "1" to set P10 pin to the

 

P1OMD (x'3F2F')

 

 

special function pin.

 

bp0

:P1OMD0

= 1

 

Set the P1DIR0 flag of the port 1 direction

 

P1DIR (x'3F31')

 

 

control register (P1DIR) to "1" for the output

 

bp0

:P1DIR0

= 1

 

mode.

 

 

 

 

 

If it needs, pull up resistor should be added.

 

 

 

 

 

[

Chapter 4. I/O Ports ]

(3)

Select the PWM operation.

(3)

Set the TM0PWM flag of the TM0MD register

 

TM0MD (x'3F54')

 

 

 

to "1", the TM0MOD flag to "0" to select the

 

bp4

:TM0PWM

= 1

 

PWM operation.

 

bp5

:TM0MOD

= 0

 

 

 

(4)

Select the count clock source.

(4)

Select "fx" for the clock source by the

 

TM0MD (x'3F54')

 

 

TM0CK2-0 flag of the TM0MD register.

 

bp2-0

:TM0CK2-0 = 010

 

 

 

 

 

 

 

 

 

 

VI - 28 8-bit PWM Output

Page 242
Image 242
Panasonic MN101C77C, F77G user manual P1DIR x3F31 Control register P1DIR to 1 for the output Bp0, PWM operation