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

📄 adcsingl.asm

📁 aduc812精典源代码下载,适合初学者
💻 ASM
字号:
;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : 28 May 1999
;
; File          : ADCsingl.asm
;
; Hardware      : ADuC812
;
; Description   : Performs repeated single ADC conversions and moves
;                 results to P0 & P2.  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 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
        CLR     LED             ; turn the LED on
        RETI

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

MAIN:

; PRECONFIGURE...

        MOV     ADCCON1,#060h   ; power up ADC
        MOV     ADCCON2,#CHAN   ; select channel to convert
        SETB	EA              ; enable interrupts
        SETB    EADC            ; enable ADC interrupt

; PERFORM REPEATED SINGLE CONVERSIONS...

AGAIN:  SETB    LED             ; turn the LED off
        CALL    DELAY           ; delay 100ms
        SETB    SCONV           ; innitiate single ADC conversion
                                ; ADC ISR is called upon completion
        CALL    DELAY           ; delay 100ms
        JMP     AGAIN           ; repeat

;____________________________________________________________________
                                                         ; 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 + -