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

📄 adcsingl.asm

📁 aduc842原程序代码 ad公司芯片应用笔记
💻 ASM
字号:
;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : October 2003
;
; File          : ADCsingl.asm
;
; Hardware      : ADuC842/ADuC843
;
; Description   : Performs repeated single ADC conversions and moves
;                 results to UART. Sets the red LED on the eval
;                 board upon completion of each conversion.  A new
;                 conversion is innitiated every 200ms.
;                 All rate calculations assume an 2.097152MHz Mclk.
;		
;********************************************************************

$MOD842                       ; Use 8052&ADuC832 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 6
;____________________________________________________________________
                                                  ; BEGINNING OF CODE
CSEG

ORG 0000h

        JMP     MAIN            ; jump to main program
;____________________________________________________________________
            

;====================================================================
                                                       ; 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

; PERFORM REPEATED SINGLE CONVERSIONS...

AGAIN:  CPL     LED             ; turn the LED off
        MOV     A,#020		; Delay length
	CALL    DELAY           ; delay 200ms

        SETB    SCONV           ; innitiate single ADC conversion
        		        ; ADC ISR is called upon completion
	JNB     ADCI,$
	
	MOV     A,ADCDATAH
	CALL    SENDVAL
	MOV     A,ADCDATAL
	CALL    SENDVAL
	
        JMP     AGAIN           ; repeat

;____________________________________________________________________
                                                         ; SUBROUTINE
DELAY:					; Delays by 10ms * A
					; 25mSec based on 2.09MHZ 
					; Core Clock 
					; i.e. default ADuC842 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 + -