Fujitsu F2MC-8L MB89620 Series Hardware Manual page 176

8-bit microcontroller
Table of Contents

Advertisement

n Program Example for PWM Timer Function
l
Processing description
Generates a PWM wave with a duty ratio of 50%. Then, changes the duty ratio to 25%.
Does not generate interrupts.
For a 10 MHz source oscillation, selecting the internal 16 t
oscillation) count clock gives a PWM wave cycle of 16 × 4 × 256/10 MHz = 1.6384 ms.
The following shows the COMR register value required for a duty ratio of 50%:
l
Coding example
CNTR
COMR
TPE
;-----Main program---------------------------------------------------------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------------------------------------------------------------------------------
MB89620 series
COMR register value = 50/100 × 256 = 128 (080H)
EQU
0012H
EQU
0013H
EQU
CNTR:3
CSEG
:
CLRB
TPE
MOV
COMR,#80H
MOV
CNTR,#10011010B
:
:
MOV
COMR,#40H
:
ENDS
END
(t
inst
inst
; Address of the PWM control register
; Address of the PWM compare register
; Define the counter operation enable bit.
; [CODE SEGMENT]
; Stop counter operation.
; Set "H" width of pulse. Duty ratio = 50%
; Operate PWM timer, select 16 t
start counter operation, clear interrupt request flag,
enable PTO pin output, and disable interrupt request output.
; Change the duty ratio to 25% (effective from the next PWM
wave cycle).
CHAPTER 7 8-BIT PWM TIMER
: divide-by-four source
,
inst
155

Advertisement

Table of Contents
loading

Table of Contents