Philips UM10109 Microscope & Magnifier User Manual


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