电路设计,软件开发,专业项目团队承接电子产品开发!


ISPRO下载型编程器
火爆销售中

RS232/TTL转换器
全IC串口窃电

RS232/TTL转换线
全IC串口窃电

ByteBlasterMV Cable
CPLD/FPGA并口下载线

ByteBlaster II Cable ISPRO下载型编程器
支持S51/AVR/PIC
超级51开发板套件
前卫实用超值

PC/MCU/CPLD
三合一学习套件

全新万年历方案
AVR单片机开发板
 

Min51单片机仿真机
迷你型

ARM7开发板
仅售260元!
 

RS-232/RS-485双向接口电平转换器  

51单片机升级STM32
火爆销售中
MPLAB-ICD2
火爆销售中
LED51开发板
玩具又名图文显示棒

面板模块/开发板
经济危机明智决择

       

GSM MODEM GSM猫

SMS短信模块 工业级/全自动
火爆销售中

大功率数传电台

高速数传电台

您当前位置:电子技术资料 -> 外围驱动 -> 片上ADC ->

祝您阅读愉快!

ISPRO下载型编程器

RS232 TO TTL转换器
↑↑本文相关产品介绍↑↑

AVR AT90S8535 ADC汇编代码


类别:技术文章
来源:未知
作者:未知
关键字:AT90S8535
加入日期:2010-8-4

;CodeVisionAVR C Compiler V1.23.7a Professional
;中国电子网www.ec66.com

;Chip type : AT90S8535
;Clock frequency : 3.690000 MHz
;Memory model : Small
;Optimize for : Size
;(s)printf features : int
;Internal SRAM size : 512
;External SRAM size : 0
;Data Stack size : 128
;Promote char to int : No
;char is unsigned : Yes
;8 bit enums : Yes
;Automatic register allocation : On
;Use AVR Studio Terminal I/O : No

.DEVICE AT90S8535
.LISTMAC
.EQU UDRE=0x5
.EQU RXC=0x7
.EQU USR=0xB
.EQU UDR=0xC
.EQU EERE=0x0
.EQU EEWE=0x1
.EQU EEMWE=0x2
.EQU SPSR=0xE
.EQU SPDR=0xF
.EQU EECR=0x1C
.EQU EEDR=0x1D
.EQU EEARL=0x1E
.EQU EEARH=0x1F
.EQU WDTCR=0x21
.EQU MCUCR=0x35
.EQU RAMPZ=0x3B
.EQU SPL=0x3D
.EQU SPH=0x3E
.EQU SREG=0x3F
.DEF R0X0=R0
.DEF R0X1=R1
.DEF R0X2=R2
.DEF R0X3=R3
.DEF R0X4=R4
.DEF R0X5=R5
.DEF R0X6=R6
.DEF R0X7=R7
.DEF R0X8=R8
.DEF R0X9=R9
.DEF R0XA=R10
.DEF R0XB=R11
.DEF R0XC=R12
.DEF R0XD=R13
.DEF R0XE=R14
.DEF R0XF=R15
.DEF R0X10=R16
.DEF R0X11=R17
.DEF R0X12=R18
.DEF R0X13=R19
.DEF R0X14=R20
.DEF R0X15=R21
.DEF R0X16=R22
.DEF R0X17=R23
.DEF R0X18=R24
.DEF R0X19=R25
.DEF R0X1A=R26
.DEF R0X1B=R27
.DEF R0X1C=R28
.DEF R0X1D=R29
.DEF R0X1E=R30
.DEF R0X1F=R31
.EQU __se_bit=0x40
.EQU __sm_mask=0x30
.EQU __sm_powerdown=0x20

.MACRO __CPD1N
CPI R30,LOW(@0)
LDI R26,HIGH(@0)
CPC R31,R26
LDI R26,BYTE3(@0)
CPC R22,R26
LDI R26,BYTE4(@0)
CPC R23,R26
.ENDM

.MACRO __CPD2N
CPI R26,LOW(@0)
LDI R30,HIGH(@0)
CPC R27,R30
LDI R30,BYTE3(@0)
CPC R24,R30
LDI R30,BYTE4(@0)
CPC R25,R30
.ENDM

.MACRO __CPWRR
CP R@0,R@2
CPC R@1,R@3
.ENDM

.MACRO __CPWRN
CPI R@0,LOW(@2)
LDI R30,HIGH(@2)
CPC R@1,R30
.ENDM

.MACRO __ADDD1N
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
SBCI R22,BYTE3(-@0)
SBCI R23,BYTE4(-@0)
.ENDM

.MACRO __ADDD2N
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
SBCI R24,BYTE3(-@0)
SBCI R25,BYTE4(-@0)
.ENDM

.MACRO __SUBD1N
SUBI R30,LOW(@0)
SBCI R31,HIGH(@0)
SBCI R22,BYTE3(@0)
SBCI R23,BYTE4(@0)
.ENDM

.MACRO __SUBD2N
SUBI R26,LOW(@0)
SBCI R27,HIGH(@0)
SBCI R24,BYTE3(@0)
SBCI R25,BYTE4(@0)
.ENDM

.MACRO __ANDD1N
ANDI R30,LOW(@0)
ANDI R31,HIGH(@0)
ANDI R22,BYTE3(@0)
ANDI R23,BYTE4(@0)
.ENDM

.MACRO __ORD1N
ORI R30,LOW(@0)
ORI R31,HIGH(@0)
ORI R22,BYTE3(@0)
ORI R23,BYTE4(@0)
.ENDM

.MACRO __DELAY_USB
LDI R24,LOW(@0)
__DELAY_USB_LOOP:
DEC R24
BRNE __DELAY_USB_LOOP
.ENDM

.MACRO __DELAY_USW
LDI R24,LOW(@0)
LDI R25,HIGH(@0)
__DELAY_USW_LOOP:
SBIW R24,1
BRNE __DELAY_USW_LOOP
.ENDM

.MACRO __CLRD1S
CLR R30
STD Y+@0,R30
STD Y+@0+1,R30
STD Y+@0+2,R30
STD Y+@0+3,R30
.ENDM

.MACRO __GETD1S
LDD R30,Y+@0
LDD R31,Y+@0+1
LDD R22,Y+@0+2
LDD R23,Y+@0+3
.ENDM

.MACRO __PUTD1S
STD Y+@0,R30
STD Y+@0+1,R31
STD Y+@0+2,R22
STD Y+@0+3,R23
.ENDM

.MACRO __POINTB1MN
LDI R30,LOW(@0+@1)
.ENDM

.MACRO __POINTW1MN
LDI R30,LOW(@0+@1)
LDI R31,HIGH(@0+@1)
.ENDM

.MACRO __POINTW1FN
LDI R30,LOW(2*@0+@1)
LDI R31,HIGH(2*@0+@1)
.ENDM

.MACRO __POINTB2MN
LDI R26,LOW(@0+@1)
.ENDM

.MACRO __POINTW2MN
LDI R26,LOW(@0+@1)
LDI R27,HIGH(@0+@1)
.ENDM

.MACRO __GETD1N
LDI R30,LOW(@0)
LDI R31,HIGH(@0)
LDI R22,BYTE3(@0)
LDI R23,BYTE4(@0)
.ENDM

.MACRO __GETD2N
LDI R26,LOW(@0)
LDI R27,HIGH(@0)
LDI R24,BYTE3(@0)
LDI R25,BYTE4(@0)
.ENDM

.MACRO __GETD2S
LDD R26,Y+@0
LDD R27,Y+@0+1
LDD R24,Y+@0+2
LDD R25,Y+@0+3
.ENDM

.MACRO __GETB1MN
LDS R30,@0+@1
.ENDM

.MACRO __GETW1MN
LDS R30,@0+@1
LDS R31,@0+@1+1
.ENDM

.MACRO __GETD1MN
LDS R30,@0+@1
LDS R31,@0+@1+1
LDS R22,@0+@1+2
LDS R23,@0+@1+3
.ENDM

.MACRO __GETBRMN
LDS R@2,@0+@1
.ENDM

.MACRO __GETWRMN
LDS R@2,@0+@1
LDS R@3,@0+@1+1
.ENDM

.MACRO __GETB2MN
LDS R26,@0+@1
.ENDM

.MACRO __GETW2MN
LDS R26,@0+@1
LDS R27,@0+@1+1
.ENDM

.MACRO __GETD2MN
LDS R26,@0+@1
LDS R27,@0+@1+1
LDS R24,@0+@1+2
LDS R25,@0+@1+3
.ENDM

.MACRO __PUTB1MN
STS @0+@1,R30
.ENDM

.MACRO __PUTW1MN
STS @0+@1,R30
STS @0+@1+1,R31
.ENDM

.MACRO __PUTD1MN
STS @0+@1,R30
STS @0+@1+1,R31
STS @0+@1+2,R22
STS @0+@1+3,R23
.ENDM

.MACRO __PUTBMRN
STS @0+@1,R@2
.ENDM

.MACRO __PUTWMRN
STS @0+@1,R@2
STS @0+@1+1,R@3
.ENDM

.MACRO __GETW1R
MOV R30,R@0
MOV R31,R@1
.ENDM

.MACRO __GETW2R
MOV R26,R@0
MOV R27,R@1
.ENDM

.MACRO __GETWRN
LDI R@0,LOW(@2)
LDI R@1,HIGH(@2)
.ENDM

.MACRO __PUTW1R
MOV R@0,R30
MOV R@1,R31
.ENDM

.MACRO __PUTW2R
MOV R@0,R26
MOV R@1,R27
.ENDM

.MACRO __ADDWRN
SUBI R@0,LOW(-@2)
SBCI R@1,HIGH(-@2)
.ENDM

.MACRO __ADDWRR
ADD R@0,R@2
ADC R@1,R@3
.ENDM

.MACRO __SUBWRN
SUBI R@0,LOW(@2)
SBCI R@1,HIGH(@2)
.ENDM

.MACRO __SUBWRR
SUB R@0,R@2
SBC R@1,R@3
.ENDM

.MACRO __ANDWRN
ANDI R@0,LOW(@2)
ANDI R@1,HIGH(@2)
.ENDM

.MACRO __ANDWRR
AND R@0,R@2
AND R@1,R@3
.ENDM

.MACRO __ORWRN
ORI R@0,LOW(@2)
ORI R@1,HIGH(@2)
.ENDM

.MACRO __ORWRR
OR R@0,R@2
OR R@1,R@3
.ENDM

.MACRO __EORWRR
EOR R@0,R@2
EOR R@1,R@3
.ENDM

.MACRO __GETWRS
LDD R@0,Y+@2
LDD R@1,Y+@2+1
.ENDM

.MACRO __PUTWSR
STD Y+@2,R@0
STD Y+@2+1,R@1
.ENDM

.MACRO __MOVEWRR
MOV R@0,R@2
MOV R@1,R@3
.ENDM

.MACRO __INWR
IN R@0,@2
IN R@1,@2+1
.ENDM

.MACRO __OUTWR
OUT @2+1,R@1
OUT @2,R@0
.ENDM

.MACRO __CALL1MN
LDS R30,@0+@1
LDS R31,@0+@1+1
ICALL
.ENDM

.MACRO __NBST
BST R@0,@1
IN R30,SREG
LDI R31,0x40
EOR R30,R31
OUT SREG,R30
.ENDM


.MACRO __PUTB1SN
LDD R26,Y+@0
LDD R27,Y+@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X,R30
.ENDM

.MACRO __PUTW1SN
LDD R26,Y+@0
LDD R27,Y+@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1SN
LDD R26,Y+@0
LDD R27,Y+@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
RCALL __PUTDP1
.ENDM

.MACRO __PUTB1SNS
LDD R26,Y+@0
LDD R27,Y+@0+1
ADIW R26,@1
ST X,R30
.ENDM

.MACRO __PUTW1SNS
LDD R26,Y+@0
LDD R27,Y+@0+1
ADIW R26,@1
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1SNS
LDD R26,Y+@0
LDD R27,Y+@0+1
ADIW R26,@1
RCALL __PUTDP1
.ENDM

.MACRO __PUTB1PMN
LDS R26,@0
LDS R27,@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X,R30
.ENDM

.MACRO __PUTW1PMN
LDS R26,@0
LDS R27,@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1PMN
LDS R26,@0
LDS R27,@0+1
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
RCALL __PUTDP1
.ENDM

.MACRO __PUTB1PMNS
LDS R26,@0
LDS R27,@0+1
ADIW R26,@1
ST X,R30
.ENDM

.MACRO __PUTW1PMNS
LDS R26,@0
LDS R27,@0+1
ADIW R26,@1
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1PMNS
LDS R26,@0
LDS R27,@0+1
ADIW R26,@1
RCALL __PUTDP1
.ENDM

.MACRO __GETB1SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
LD R30,Z
.ENDM

.MACRO __GETW1SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
LD R0,Z+
LD R31,Z
MOV R30,R0
.ENDM

.MACRO __GETD1SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
LD R0,Z+
LD R1,Z+
LD R22,Z+
LD R23,Z
MOV R30,R0
MOV R31,R1
.ENDM

.MACRO __GETB2SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R26,X
.ENDM

.MACRO __GETW2SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R0,X+
LD R27,X
MOV R26,R0
.ENDM

.MACRO __GETD2SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R0,X+
LD R1,X+
LD R24,X+
LD R25,X
MOV R26,R0
MOV R27,R1
.ENDM

.MACRO __GETBRSX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@1)
SBCI R31,HIGH(-@1)
LD R@0,Z
.ENDM

.MACRO __GETWRSX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@2)
SBCI R31,HIGH(-@2)
LD R@0,Z+
LD R@1,Z
.ENDM

.MACRO __LSLW8SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
LD R31,Z
CLR R30
.ENDM

.MACRO __PUTB1SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
ST X,R30
.ENDM

.MACRO __PUTW1SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1SX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
ST X+,R30
ST X+,R31
ST X+,R22
ST X,R23
.ENDM

.MACRO __CLRW1SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
CLR R0
ST Z+,R0
ST Z,R0
.ENDM

.MACRO __CLRD1SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
CLR R0
ST Z+,R0
ST Z+,R0
ST Z+,R0
ST Z,R0
.ENDM

.MACRO __PUTB2SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
ST Z,R26
.ENDM

.MACRO __PUTW2SX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
ST Z+,R26
ST Z,R27
.ENDM

.MACRO __PUTBSRX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@0)
SBCI R31,HIGH(-@0)
ST Z,R@1
.ENDM

.MACRO __PUTWSRX
MOV R30,R28
MOV R31,R29
SUBI R30,LOW(-@2)
SBCI R31,HIGH(-@2)
ST Z+,R@0
ST Z,R@1
.ENDM

.MACRO __PUTB1SNX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R0,X+
LD R27,X
MOV R26,R0
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X,R30
.ENDM

.MACRO __PUTW1SNX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R0,X+
LD R27,X
MOV R26,R0
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X+,R30
ST X,R31
.ENDM

.MACRO __PUTD1SNX
MOV R26,R28
MOV R27,R29
SUBI R26,LOW(-@0)
SBCI R27,HIGH(-@0)
LD R0,X+
LD R27,X
MOV R26,R0
SUBI R26,LOW(-@1)
SBCI R27,HIGH(-@1)
ST X+,R30
ST X+,R31
ST X+,R22
ST X,R23
.ENDM

.CSEG
.ORG 0

.INCLUDE "adc8535.vec"
.INCLUDE "adc8535.inc"
__RESET:
CLI
CLR R30
OUT EECR,R30
OUT MCUCR,R30

;DISABLE WATCHDOG
LDI R31,0x18
OUT WDTCR,R31
LDI R31,0x10
OUT WDTCR,R31

;CLEAR R2-R14
LDI R24,13
LDI R26,2
CLR R27
__CLEAR_REG:
ST X+,R30
DEC R24
BRNE __CLEAR_REG

;CLEAR SRAM
LDI R24,LOW(0x200)
LDI R25,HIGH(0x200)
LDI R26,0x60
__CLEAR_SRAM:
ST X+,R30
SBIW R24,1
BRNE __CLEAR_SRAM

;GLOBAL VARIABLES INITIALIZATION
LDI R30,LOW(__GLOBAL_INI_TBL*2)
LDI R31,HIGH(__GLOBAL_INI_TBL*2)
__GLOBAL_INI_NEXT:
LPM
ADIW R30,1
MOV R1,R0
LPM
ADIW R30,1
MOV R22,R30
MOV R23,R31
MOV R31,R0
MOV R30,R1
SBIW R30,0
BREQ __GLOBAL_INI_END
LPM
ADIW R30,1
MOV R26,R0
LPM
ADIW R30,1
MOV R27,R0
LPM
ADIW R30,1
MOV R24,R0
LPM
ADIW R30,1
MOV R25,R0
__GLOBAL_INI_LOOP:
LPM
ADIW R30,1
ST X+,R0
SBIW R24,1
BRNE __GLOBAL_INI_LOOP
MOV R30,R22
MOV R31,R23
RJMP __GLOBAL_INI_NEXT
__GLOBAL_INI_END:

;STACK POINTER INITIALIZATION
LDI R30,LOW(0x25F)
OUT SPL,R30
LDI R30,HIGH(0x25F)
OUT SPH,R30

;DATA STACK POINTER INITIALIZATION
LDI R28,LOW(0xE0)
LDI R29,HIGH(0xE0)

RJMP _main

.ESEG
.ORG 0
.DB 0 ; FIRST EEPROM LOCATION NOT USED, SEE ATMEL ERRATA SHEETS

.DSEG
.ORG 0xE0
; 1 /*
; 2 ADC example for the AT90S8535 on
; 3 the Atmel STK500 starter kit
; 4
; 5 CodeVisionAVR C Compiler
; 6 ?Copyright 2001-2002 HP InfoTech S.R.L.
; 7 www.hpinfotech.ro
; 8
; 9 Set the following jumpers on the STK500 board:
; 10 VTARGET, AREF, RESET, XTAL1, OSCSEL: 1-2
; 11
; 12 Connect the PORTB and LEDS headers with
; 13 a 10 wire ribbon cable
; 14
; 15 Connect the ISP6PIN and SPROG3 headers with
; 16 a 6 wire ribbon cable
; 17
; 18 The AT90S8535 must be located on socket SCKT3100A3
; 19
; 20 In the AVR Studio Tools|STK500|Board window set:
; 21 - VTarget=5.0V
; 22 - ARef=5.0V
; 23 - Oscillator=3.69MHz
; 24
; 25 Apply a positive DC voltage in the 0..5.0V range
; 26 between the PORTA header PA0 and GND pins
; 27 */
; 28
; 29 // I/O register definitions for AT90S8535
; 30 #include <90s8535.h>
; 31 // delay functions
; 32 #include <delay.h>
; 33
; 34 #define ADC_VREF_TYPE 0x00
; 35 // ADC interrupt service routine
; 36 interrupt [ADC_INT] void adc_isr(void)
; 37 {

.CSEG
; 38 // The LEDs will display the 8 most
; 39 // semnificative ADC bits
; 40 PORTB=(unsigned char) ~(ADCW>>2);
; 41 // 20ms delay
; 42 delay_ms(20);
; 43 // Start a new AD conversion
; 44 ADCSR|=0x40;
; 45 }
; 46
; 47 void main(void)
; 48 {
; 49 // Port B initialization
; 50 PORTB=0xFF; // all outputs
; 51 DDRB=0xFF; // all LEDs are initially off
; 52
; 53 // ADC initialization
; 54 // ADC Clock frequency: 57.656 kHz
; 55 // ADC Interrupts: On
; 56 ADCSR=0x8E;
; 57
; 58 // Global enable interrupts
; 59 #asm("sei")
sei
; 60
; 61 // Select ADC input 0
; 62 ADMUX=0;
; 63
; 64 // Start the first AD conversion
; 65 ADCSR|=0x40;
; 66
; 67 // All the job is done by ADC interrupts
; 68 while (1);
; 69 }

_delay_ms:
ld r30,y+
ld r31,y+
adiw r30,0
breq __delay_ms1
__delay_ms0:
__DELAY_USW 0x39A
wdr
sbiw r30,1
brne __delay_ms0
__delay_ms1:
ret

__SAVEISR:
ST -Y,R0
ST -Y,R1
ST -Y,R15
ST -Y,R22
ST -Y,R23
ST -Y,R24
ST -Y,R25
ST -Y,R26
ST -Y,R27
ST -Y,R30
ST -Y,R31
IN R0,SREG
ST -Y,R0
RET

__LOADISR:
LD R0,Y+
OUT SREG,R0
LD R31,Y+
LD R30,Y+
LD R27,Y+
LD R26,Y+
LD R25,Y+
LD R24,Y+
LD R23,Y+
LD R22,Y+
LD R15,Y+
LD R1,Y+
LD R0,Y+
RET


您可能还会关注的相关技术资料:

中国电子网
www.EC66.com
QQ:34740080 EMAIL:iloveaoe@163.com
最佳浏览:1024*768
Copyright (C) 2001-2010 EC66.COM All Rights Reserved
Aoe/帝国 制作维护
粤ICP备18061901号