XC912BC32CFU8 Motorola Semiconductor Products, XC912BC32CFU8 Datasheet - Page 148

no-image

XC912BC32CFU8

Manufacturer Part Number
XC912BC32CFU8
Description
M68HC12B Family Data Sheet
Manufacturer
Motorola Semiconductor Products
Datasheet
Pulse-Width Modulator (PWM)
11.4.3 Code Listing
INCLUDE 'EQUATES.ASM'
; ----------------------------------------------------------------------
;
; ----------------------------------------------------------------------
;
MAIN:
;
;
;
DONE:
;* --------------------------------------------------------
;*
;* --------------------------------------------------------
TIMERINIT:
;
;
;
;
;
;
Data Sheet
148
Subroutine TIMERINIT: Initialize Timer for PWM on OC5
ORG
BSR
BRA
CLR
MOVB
MOVB
MOVB
MOVB
MOVB
MOVW
MOVW
MOVB
RTS
NOTE:
MAIN PROGRAM
$7000
TIMERINIT
DONE
TMSK1
#$0A,TMSK2
#$88,TCTL1
#$A0,TIOS
#$20,OC7M
#$20,OC7D
#$0800,TC7H
#$0400,TC5H
#$80,TSCR
A comment line is deliminted by a semi-colon. If there is no code before comment,
an “;” must be placed in the first column to avoid assembly errors.
; Equates for all registers
; 16K On-Board RAM, User code data area,
; start main program at $7000
; Subroutine used to initialize the timer:
; Out. comp. chan. using OC7 & OC5,
; no interrupts
; OC7 = PERIOD & OC5 = HIGH TIME of PWM
; Branch to itself, Convinient for Breakpoint
; Disable All Interrupts
; Disable overflow interrupt, disable pull-up
; resistor function with normal drive capability
; and Cntr reset by a succesful OC7 compare,
; Prescaler = sys clock / 4.
; Init. OC5 to Clear ouput line to zero on
; successful compare.
; Select Channel 5 and 7 to act as output compare.
; Initialize OC7 compare to affect OC5 pin(OC7M)
; Enable OC7 to set output compare 5 pin high(OC7D).
; Load TC7 with "PERIOD" of the PWM
; Load TC5 with "HIGH TIME" of the PWM.
; Enable Timer, Timer runs during wait state,
; and while in Background Mode, also clear flags
; normally.
; Return from Subroutine
Pulse-Width Modulator (PWM)
M68HC12B Family — Rev. 8.0
MOTOROLA

Related parts for XC912BC32CFU8