Comparators Configuration Example - Philips P89LPC938 User Manual

Single-chip microcontroller
Table of Contents

Advertisement

Philips Semiconductors
Fig 47. Comparator configurations.

14.6 Comparators configuration example

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:
MOV PT0AD,#030h
ANL P0M2,#0CFh
ORL P0M1,#030h
MOV CMP1,#024h
CALL delay10us
ANL CMP1,#0FEh
SETB EC
SETB EA
RET
The interrupt routine used for the comparator must clear the interrupt flag (CMF1 in this
case) before returning
User manual
CINnA
CMPREF
002aaa618
a. CPn, CNn, OEn = 0 0 0
CINnA
V
(1.23 V)
REF
002aaa621
c. CPn, CNn, OEn = 0 1 0
CINnB
CMPREF
002aaa623
e. CPn, CNn, OEn = 1 0 0
CINnB
V
(1.23V)
REF
002aaa625
g. CPn, CNn, OEn = 1 1 0
Rev. 03 — 7 June 2005
COn
b. CPn, CNn, OEn = 0 0 1
COn
V
d. CPn, CNn, OEn = 0 1 1
COn
f. CPn, CNn, OEn = 1 0 1
COn
V
h. CPn, CNn, OEn = 1 1 1
;Disable digital INPUTS on CIN1A, CMPREF.
;Disable digital OUTPUTS on pins that are used
;for analog functions: CIN1A, CMPREF.
;Turn on comparator 1 and set up for:
;Positive input on CIN1A.
;Negative input from CMPREF pin.
;Output to CMP1 pin enabled.
;The comparator needs at least 10 microseconds before use.
;Clear comparator 1 interrupt flag.
;Enable the comparator interrupt,
;Enable the interrupt system (if needed).
;Return to caller.
UM10119
P89LPC938 User manual
COn
CINnA
CMPn
CMPREF
002aaa620
COn
CINnA
CMPn
(1.23 V)
REF
002aaa622
COn
CINnB
CMPn
CMPREF
002aaa624
COn
CINnB
CMPn
(1.23 V)
REF
002aaa626
© Koninklijke Philips Electronics N.V. 2005. All rights reserved.
103 of 139

Advertisement

Table of Contents
loading

Table of Contents