Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
10
Table 1. Example A/D Conversion Times
CPU Clock Rate
RCCLK = 0
RCCLK = 1
CPU
Clock
Rate
RCCLK
=
0
minimum nominal maximum
32 kHz NA 563.4 µs 659 µs 757 µs
1 MHz 186 µs 32.4 µs 39.3 µs 48.9 µs
4 MHz 46.5 µs 18.9 µs 23.6 µs 30.1 µs
11.0592 MHz 16.8 µs 16 µs 20.2 µs 27.1 µs
12 MHz 15.5 µs
16 MHz 11.6 µs
20 MHz 9.3 µs
Note: Do not clock ADC from the RC oscillator when MCU clock is greater than 4 MHz.
AD0 (P0.3)
AD1 (P0.4)
V
REF
+ = V
DD
AADR1
AD2 (P0.5)
AD3 (P0.6)
00
01
10
11
V
REF
- = V
SS
ADCON
A/D Converter
AADR0
DAC0
(A/D result)
SU01356
Figure 3. A/D Converter Connections
The A/D in Power Down and Idle Modes
While using the CPU clock as the A/D clock source, the Idle mode
may be used to conserve power and/or to minimize system noise
during the conversion. CPU operation will resume and Idle mode
terminate automatically when a conversion is complete if the A/D
interrupt is active. In Idle mode, noise from the CPU itself is
eliminated, but noise from the oscillator and any other on-chip
peripherals that are running will remain.
The CPU may be put into Power Down mode when the A/D is
clocked by the on-chip RC oscillator (RCCLK = 1). This mode gives
the best possible A/D accuracy by eliminating most on-chip noise
sources.
If the Power Down mode is entered while the A/D is running from the
CPU clock (RCCLK = 0), the A/D will abort operation and will not
wake up the CPU. The contents of DAC0 will be invalid when
operation does resume.
When an A/D conversion is started, Power Down or Idle mode must
be activated within two machine cycles in order to have the most
accurate A/D result. These two machine cycles are counted at the
CPU clock rate. When using the A/D with either Power Down or Idle
mode, care must be taken to insure that the CPU is not restarted by
another interrupt until the A/D conversion is complete. The possible
causes of wakeup are different in Power Down and Idle modes.
A/D accuracy is also affected by noise generated elsewhere in the
application, power supply noise, and power supply regulation. Since
the P87LPC767 power pins are also used as the A/D reference and
supply, the power supply has a very direct affect on the accuracy of
A/D readings. Using the A/D without Power Down mode while the
clock is divided through the use of CLKR or DIVM has an adverse
effect on A/D accuracy.
Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
11
Code Examples for the A/D
The first piece of sample code shows an example of port configuration for use with the A/D. This example sets up the pins so that all four A/D
channels may be used. Port configuration for analog functions is described in the section Analog Functions.
; Set up port pins for A/D conversion, without affecting other pins.
mov PT0AD,#78h ; Disable digital inputs on A/D input pins.
anl P0M2,#87h ; Disable digital outputs on A/D input pins.
orl P0M1,#78h ; Disable digital outputs on A/D input pins.
Following is an example of using the A/D with interrupts. The routine ADStart begins an A/D conversion using the A/D channel number supplied
in the accumulator. The channel number is not checked for validity. The A/D must previously have been enabled with sufficient time to allow for
stabilization.
The interrupt handler routine reads the conversion value and returns it in memory address ADResult. The interrupt should be enabled prior to
starting the conversion.
; Start A/D conversion.
ADStart:
orl ADCON,A ; Add in the new channel number.
setb ADCS ; Start an A/D conversion.
; orl PCON,#01h ; The CPU could be put into Idle mode here.
; orl PCON,#02h ; The CPU could be put into Power Down mode here if RCCLK = 1.
ret
; A/D interrupt handler.
ADInt:
push ACC ; Save accumulator.
mov A,DAC0 ; Get A/D result,
mov ADResult,A ; and save it in memory.
clr ADCI ; Clear the A/D completion flag.
anl ADCON,#0fch ; Clear the A/D channel number.
pop ACC ; Restore accumulator.
reti
Following is an example of using the A/D with polling. An A/D conversion is started using the channel number supplied in the accumulator. The
channel number is not checked for validity. The A/D must previously have been enabled with sufficient time to allow for stabilization. The
conversion result is returned in the accumulator.
ADRead:
orl ADCON,A ; Add in the new channel number.
setb ADCS ; Start A/D conversion.
ADChk:
jnb ADCI,ADChk ; Wait for ADCI to be set.
mov A,DAC0 ; Get A/D result.
clr ADCI ; Clear the A/D completion flag.
anl ADCON,#0fch ; Clear the A/D channel number.
ret
Philips Semiconductors Product data
P87LPC767
Low power, low price, low pin count (20 pin)
microcontroller with 4-kbyte OTP and 8-bit A/D converter
2002 Mar 25
12
Analog Comparators
Two analog comparators are provided on the P87LPC767. Input and
output options allow use of the comparators in a number of different
configurations. Comparator operation is such that the output is a
logical one (which may be read in a register and/or routed to a pin)
when the positive input (one of two selectable pins) is greater than
the negative input (selectable from a pin or an internal reference
voltage). Otherwise the output is a zero. Each comparator may be
configured to cause an interrupt when the output value changes.
Comparator Configuration
Each comparator has a control register, CMP1 for comparator 1 and
CMP2 for comparator 2. The control registers are identical and are
shown in Figure 4.
The overall connections to both comparators are shown in Figure 5.
There are eight possible configurations for each comparator, as
determined by the control bits in the corresponding CMPn register:
CPn, CNn, and OEn. These configurations are shown in Figure 6.
The comparators function down to a V
DD
of 3.0 V.
When each comparator is first enabled, the comparator output and
interrupt flag are not guaranteed to be stable for 10 microseconds.
The corresponding comparator interrupt should not be enabled
during that time, and the comparator interrupt flag must be cleared
before the interrupt is enabled in order to prevent an immediate
interrupt service.
BIT SYMBOL FUNCTION
CMPn.7, 6 Reserved for future use. Should not be set to 1 by user programs.
CMPn.5 CEn Comparator enable. When set by software, the corresponding comparator function is enabled.
Comparator output is stable 10 microseconds after CEn is first set.
CMPn.4 CPn Comparator positive input select. When 0, CINnA is selected as the positive comparator input. When
1, CINnB is selected as the positive comparator input.
CMPn.3 CNn Comparator negative input select. When 0, the comparator reference pin CMPREF is selected as
the negative comparator input. When 1, the internal comparator reference V
ref
is selected as the
negative comparator input.
CMPn.2 OEn Output enable. When 1, the comparator output is connected to the CMPn pin if the comparator is
enabled (CEn = 1). This output is asynchronous to the CPU clock.
CMPn.1 COn Comparator output, synchronized to the CPU clock to allow reading by software. Cleared when the
comparator is disabled (CEn = 0).
CMPn.0 CMFn Comparator interrupt flag. This bit is set by hardware whenever the comparator output COn changes
state. This bit will cause a hardware interrupt if enabled and of sufficient priority. Cleared by
software and when the comparator is disabled (CEn = 0).
CMFn
SU01152
COnOEnCNnCPnCEn
01234567
CMPn
Reset Value: 00h
Not Bit Addressable
Address: ACh for CMP1, ADh for CMP2
Figure 4. Comparator Control Registers (CMP1 and CMP2)

P87LPC767FN,112

Mfr. #:
Manufacturer:
NXP Semiconductors
Description:
IC MCU 8BIT 4KB OTP 20DIP
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union