p87lpc778 NXP Semiconductors, p87lpc778 Datasheet - Page 20

no-image

p87lpc778

Manufacturer Part Number
p87lpc778
Description
Cmos Single-chip 8-bit 80c51 Microcontroller 128-byte Data Ram, 8 Kb Otp
Manufacturer
NXP Semiconductors
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
p87lpc778FDH
Manufacturer:
PHILIPS/飞利浦
Quantity:
20 000
Part Number:
p87lpc778FDH/CP3242
Manufacturer:
SAMSUNG
Quantity:
50
Part Number:
p87lpc778FDH/CP3242
Manufacturer:
PHILIPS/飞利浦
Quantity:
20 000
Philips Semiconductors
9397 750 12378
Product data
8.5.5 Comparator configuration example
8.6 Pulse width modulator
The code shown below is an example of initializing one comparator. Comparator 1 is
configured to use the CIN1A and CMPREF inputs, outputs the comparator result to
the CMP1 pin, and generates an interrupt when the comparator output changes.
CmpInit: b
The interrupt routine used for the comparator must clear the interrupt flag (CMF1 in
this case) before returning.
The P87LPC778 contains four Pulse Width Modulated (PWM) channels which can
generate pulses of programmable length and interval.
The output for PWM0 is on P0.1, PWM1 on P1.6, PWM2 on P1.7 and PWM3 on
P0.0.
After chip reset the output of the each PWM channel is reflect by the setting of
UCFG1.5, PRHI, if set to a zero the outputs are low, if set to one the outputs are high.
In this case PRHI is set to zero, before the pin will reflect the state of the internal
PWM output a ‘1’ must be written to each port bit that serves as a PWM output.
A block diagram is shown in
The interval between successive outputs is controlled by a 10–bit down counter
which uses the internal microcontroller clock as its input.
When bit 3 in the UCFG1 register is a ‘1’ (6-clock mode) the microcontroller clock,
and therefore the PWM counter clock, has the same frequency as the clock source:
When bit 3 in the UCFG1 register is a ‘0’ (12-clock mode) the microcontroller and
PWM counter clocks operate at half the frequency of clock source:
f
f
CPWM
CPWM
mov
anl
orl
mov
call
anl
setb
setb
ret
=
=
PT0AD,#30h
P0M2,#0cfh
P0M1,#30h
CMP1,#24h
delay10us
CMP1,#0feh
EC1
EA
------------
f
f
OSC
OSC
2
Rev. 01 — 31 March 2004
; Disable digital inputs on pins that are used
;
; Disable digital outputs on pins that are used
;
; Turn on comparator 1 and set up for:
;
;
;
; The comparator has to start up for at
;
; Clear comparator 1 interrupt flag.
; Enable the comparator 1 interrupt. The
;
; Enable the interrupt system (if needed).
; Return to caller.
Figure
for analog functions: CIN1A, CMPREF.
for analog functions: CIN1A, CMPREF.
- Positive input on CIN1A.
- Negative input from CMPREF pin.
- Output to CMP1 pin enabled.
least 10 microseconds before use.
priority is left at the current value.
8.
CMOS single-chip 8-bit microcontroller
© Koninklijke Philips Electronics N.V. 2004. All rights reserved.
P87LPC778
20 of 79
(2)
(3)

Related parts for p87lpc778