p87lpc778 NXP Semiconductors, p87lpc778 Datasheet - Page 16

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.4.2 Code examples for the A/D
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.
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
on page
; Set up port pins for A/D conversion, without affecting other 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
; orl
RCCLK = 1.
; A/D interrupt handler.
ADInt:
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:
ADChk:
push
mov
mov
clr
anl
pop
ret
orl
setb ADCS
jnb
mov
clr
anl
ret
orl
setb
ret
mov
anl
orl
ADCON,A
ADCI,ADChk
A,DAC0
ADCI
ADCON,#0fch
ACC
A,DAC0
ADResult,A
ADCI
ADCON,#0fch ; Clear the A/D channel number.
ACC
12.
ADCON,A
ADCS
PCON,#01h
PCON,#02h
PT0AD,#78h
P0M2,#87h
P0M1,#78h
Rev. 01 — 31 March 2004
; Add in the new channel number.
; Start an A/D conversion.
; The CPU could be put into Idle mode here.
; The CPU could be put into Power-down mode here if
; Save accumulator.
; Get A/D result, by reading DAC0 SFR
; and save it in memory.
; Clear the A/D completion flag.
; Restore accumulator.
; Add in the new channel number.
; Start A/D conversion.
; Wait for ADCI to be set.
; Get A/D result.
; Clear the A/D completion flag.
; Clear the A/D channel number.
; Disable digital inputs on A/D input pins.
; Disable digital outputs on A/D input pins.
; Disable digital outputs on A/D input pins.
CMOS single-chip 8-bit microcontroller
© Koninklijke Philips Electronics N.V. 2004. All rights reserved.
Section 8.2 “Analog functions”
P87LPC778
16 of 79

Related parts for p87lpc778