📄 adcpin.asm
字号:
;********************************************************************
;
; Author : ADI - Apps www.analog.com/MicroConverter
;
; Date : 15 July 1999
;
; File : ADCpin.asm
;
; Hardware : ADuC812
;
; Description : Performs hardware pin driven ADC conversions and
; outputs results on P0 & P2. Continuously flashes
; LED (independently of ADC routine) at approximately
; 5Hz (assuming an 11.0592MHz Mclk).
;
;********************************************************************
$MOD812 ; Use 8052&ADuC812 predefined symbols
LED EQU P3.4 ; P3.4 drives red LED on eval board
CHAN EQU 0 ; convert this ADC input channel..
; ..chan values can be 0 thru 8
;____________________________________________________________________
; BEGINNING OF CODE
CSEG
ORG 0000h
JMP MAIN ; jump to main program
;____________________________________________________________________
; INTERRUPT VECTOR SPACE
ORG 0033H ; (ADC ISR)
MOV P0,ADCDATAL ; ADC result low byte to Port0
MOV P2,ADCDATAH ; high nibble and channel ID to Port2
RETI
;====================================================================
; MAIN PROGRAM
ORG 004Bh
MAIN:
; PRECONFIGURE...
MOV ADCCON1,#064h ; power up ADC, 6.51us conv+acq time
MOV ADCCON2,#CHAN ; select channel to convert
; LAUNCH CONTINUOUS CONVERSIONS...
SETB EA ; enable interrupts
SETB EADC ; enable ADC interrupt
ORL ADCCON1,#001h ; enable hardware CONVST pin
; CONTINUE WITH OTHER CODE...
AGAIN: CPL LED ; blink (complement) the LED
CALL DELAY ; delay 100ms
JMP AGAIN ; repeat
; the micro is free to continue with other tasks (flashing the LED in
; this case) while the ADC is converting, synchronously to the
; external CONVST pin. results are being handled by the ADC
; interrupt service routine.
;____________________________________________________________________
; SUBROUTINE
DELAY: ; delay 100ms
MOV R7,#200 ; 200 * 500us = 100ms
DLY1: MOV R6,#229 ; 229 * 2.17us = 500us
DJNZ R6,$ ; sit here for 500us
DJNZ R7,DLY1 ; repeat 200 times (100ms total)
RET
;____________________________________________________________________
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -