📄 adcpin.asm
字号:
;********************************************************************
;
; Author : ADI - Apps www.analog.com/MicroConverter
;
; Date : April 2002
;
; File : ADCpin.asm
;
; Hardware : ADuC814
;
; Description : Performs hardware pin driven ADC conversions and
; outputs results on the UART Continuously flashes
; LED (independently of ADC routine) at approximately
; 5Hz (assuming an 2.097152 MHz Mclk).
;
;********************************************************************
$MOD814 ; Use 8052&ADuC814 predefined symbols
LED EQU P3.3 ; P3.3 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 A,ADCDATAH
CALL SENDVAL
MOV A,ADCDATAL
CALL SENDVAL
RETI
;====================================================================
; MAIN PROGRAM
ORG 004Bh
MAIN:
; Set up UART
MOV RCAP2H,#0FFh ; config UART for 9600 baud
MOV RCAP2L,#-7 ;
MOV TH2,#0FFh
MOV TL2,#-7
MOV SCON,#52h
MOV T2CON,#34h
; PRECONFIGURE...
MOV ADCCON1,#080h ; power up ADC
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
MOV A,#01H ; delay length
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: ; Delays by 100ms * A
; 100mSec based on 2.097152MHZ
; Core Clock
; i.e. default ADuC814 Clock
MOV R1,A ; Acc holds delay variable
DLY0: MOV R2,#022h ; Set up delay loop0
DLY1: MOV R3,#0FFh ; Set up delay loop1
DJNZ R3,$ ; Dec R3 & Jump here until R3 is 0
DJNZ R2,DLY1 ; Dec R2 & Jump DLY1 until R2 is 0
DJNZ R1,DLY0 ; Dec R1 & Jump DLY0 until R1 is 0
RET ; Return from subroutine
;____________________________________________________________________
$INCLUDE(UARTIO.ASM)
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -