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

📄 新建 文本文档 (3).txt

📁 ADuC812与8052模数转换实例 先进的单片机平台 可以做很多东西 比如 光电心率测量仪
💻 TXT
字号:

; 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.
; 
;********************************************************************

$INCLUDE (ADuC812.inc) ; 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
SETB 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: CLR 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 + -