⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adcpin.asm

📁 aduc842原程序代码 ad公司芯片应用笔记
💻 ASM
字号:
;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : October 2003
;
; File          : ADCpin.asm
;
; Hardware      : ADuC842/ADuC843
;
; 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).
;		
;********************************************************************

$MOD842                         ; Use 8052&ADuC842 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 A,ADCDATAH
	CALL SENDVAL
	MOV A,ADCDATAL
	CALL SENDVAL	
        RETI

;====================================================================
                                                       ; MAIN PROGRAM
ORG 004Bh

MAIN:

; Set up UART
	MOV	T3CON,#083h
	MOV	T3FD,#02DH
	MOV	SCON,#52H
; PRECONFIGURE...

        MOV     ADCCON1,#0ACh   ; 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,#010		; 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 10ms * A
					; 10mSec based on 2.097152MHz
					; Core Clock 
					; 

		MOV	R1,A		; Acc holds delay variable (1 clock)
 DLY0:		MOV	R2,#01Bh	; Set up delay loop0 (2 clocks)
 DLY1:		MOV	R3,#0FFh	; Set up delay loop1 (2 clocks)
		DJNZ	R3,$		; Dec R3 & Jump here until R3 is 0 (3 clocks)
		DJNZ	R2,DLY1         ; Dec R2 & Jump DLY1 until R2 is 0 (3 clocks)
		DJNZ	R1,DLY0		; Dec R1 & Jump DLY0 until R1 is 0 (3 clocks)
		RET			; Return from subroutine

;____________________________________________________________________

$INCLUDE(UARTIO.ASM)
END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -