159
CHAPTER 7 8-BIT PWM TIMER
■
Program Example of PWM Timer Functions
●
Processing specifications
•
A PWM wave with a duty ratio of 50% is generated. The duty ratio is then changed to 25%.
•
No interrupt occurs.
•
When the count clock is 16 t
INST
of an internal count clock, the cycle of the PWM wave is 16
×
4/12.5
MHz
×
256 = 1.3107 ms, which occurs when the top speed of the gear (one instruction cycle = 4/F
CH
) is
obtained at an oscillation frequency of 12.5 MHz.
•
The COMR register value with a duty ratio of 50% is shown below.
COMR register value = 50/100
×
256 = 128 (080
H
)
●
Coding example
CNTR
EQU
0022H
; Address of the PWM control register
COMR EQU
0023H
; Address of the PWM compare register
TPE
EQU
CNTR:3
; Defining the bit to enable the counter operation
;------------------------Main program---------------------------------------------------------------------------------
CSEG
; [CODE SEGMENT]
:
CLRB
TPE
; Stopping the counter operation
MOV
COMR,#80H
; Specification of the H-level width of a pulse, 50% duty
ratio
MOV
CNTR,#10011010B
; PWM timer operation, selection of 16 t
INST
; Starting the counter operation, clearing the interrupt
request flag
; Enabling the output of the PWM pin, disabling the output
of interrupt requests
:
:
MOV
COMR,#40H
; Changing the duty ratio to 25% (Takes effect at the next
cycle of the PWM wave.)
:
ENDS
;---------------------------------------------------------------------------------------------------------------------
END
Summary of Contents for F2MC-8L F202RA
Page 2: ......
Page 4: ......
Page 32: ...16 CHAPTER 1 OVERVIEW ...
Page 90: ...74 CHAPTER 3 CPU ...
Page 142: ...126 CHAPTER 5 TIME BASE TIMER POPW A RETI ENDS END ...
Page 150: ...134 CHAPTER 6 WATCHDOG TIMER ...
Page 176: ...160 CHAPTER 7 8 BIT PWM TIMER ...
Page 220: ...204 CHAPTER 8 8 16 BIT CAPTURE TIMER COUNTER ...
Page 240: ...224 CHAPTER 9 12 BIT PPG TIMER ...
Page 274: ...258 CHAPTER 11 EXTERNAL INTERRUPT CIRCUIT 2 LEVEL ...
Page 362: ...346 CHAPTER 15 BUZZER OUTPUT ...
Page 390: ...374 CHAPTER 17 FLASH MEMORY ...
Page 419: ...403 INDEX INDEX The index follows on the next page This is listed in alphabetic order ...
Page 434: ...418 INDEX ...
Page 436: ......