Program Example For 8-Bit Pwm Timer - Fujitsu F2MC-8L MB89620 Series Hardware Manual

8-bit microcontroller
Table of Contents

Advertisement

9
7.

Program Example for 8-bit PWM Timer

This section gives program examples for the 8-bit PWM timer.
n Program Example for Interval Timer Function
l
Processing description
Generates repeated interval timer interrupts at 5 ms intervals.
Outputs a square wave to the PTO pin that inverts after each interval time.
The following shows the COMR register value that results in an interval time of
approximately 5 ms for a 10 MHz source oscillation. The internal 64 t
source oscillation) count clock is selected.
l
Coding example
CNTR
COMR
TPE
TIR
ILR2
INT_V
IRQ4
INT_V
;-----Main program---------------------------------------------------------------------------------------------------------------------------------------
;-----Interrupt program----------------------------------------------------------------------------------------------------------------------------------
WARI
;--------------------------------------------------------------------------------------------------------------------------------------------------------------
154
CHAPTER 7 8-BIT PWM TIMER
COMR register value = 5 ms/(64 × 4/10 MHz)
EQU
0012H
EQU
0013H
EQU
CNTR:3
EQU
CNTR:2
EQU
007DH
DSEG
ABS
ORG
0FFF2H
DW
WARI
ENDS
CSEG
:
CLRI
CLRB
TPE
MOV
ILR2,#11111101B
MOV
COMR,#0C2H
MOV
CNTR,#00101011B
SETI
:
CLRB
TIR
PUSHW
A
XCHW
A,T
PUSHW
A
:
User processing
:
POPW
A
XCHW
A,T
POPW
A
RETI
ENDS
END
1 = 194.3 (0C2H)
; Address of the PWM control register
; Address of the PWM compare register
; Define the counter operation enable bit.
; Define the interrupt request flag bit.
; Address of the interrupt level setting register 2
; [DATA SEGMENT]
; Set interrupt vector.
; [CODE SEGMENT]
; Stack pointer (SP) etc. are already initialized.
; Disable interrupts.
; Stop counter operation.
; Set interrupt level (level 1).
; Value compared with the counter value (interval time)
; Operate interval timer, select 64 t
start counter operation, clear interrupt request flag,
enable PTO pin output, enable interrupt request output.
; Enable interrupts.
; Clear interrupt request flag.
; Save A and T.
; Restore A and T.
(t
: divide-by-four
inst
inst
,
inst
MB89620 series

Advertisement

Table of Contents
loading

Table of Contents