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

📄 dip40~2.lst

📁 单片机开发资料光盘-双龙-686M.zip
💻 LST
字号:

AVRASM ver. 1.30  DIP40~2.ASM Mon Jun 25 21:41:01 2001


         ;************* 应用笔记  DIP40B.asm  ************************
         ;*
         ;* 标题:	测试DIP40封装器件I/O口功能
         ;* 版本:		1.0
         ;*最后更新日期:	2000.08.08
         ;*
         ;* 支援 E-mail:	gzsl@sl.com.cn
         ;*
         ;* 描述
         ;*       用实验器测试A口、B口、C口、D口LED循环移位
         ;* 作者: SL.
         ;*程序适用于所有单片机
         ;***************************************************************************
         ;	DIP40 AT90S8515引脚排列图,"*"表示引脚上接LED灯
         ;				"↓↑"表示LED亮灯移动方向
         ;
         ;	PB0  ↓* 。1	40 。VCC
         ;	PB1  ↓* 。	   。* ↑ PA0
         ;	PB2  ↓* 。	   。* ↑ PA1
         ;  	PB3  ↓* 。	   。* ↑ PA2
         ;	PB4  ↓* 。	   。* ↑ PA3
         ;	PB5  ↓* 。	   。* ↑ PA4
         ;       PB6  ↓* 。	   。* ↑ PA5
         ;	PB7  ↓* 。	   。* ↑ PA6
         ;      /RESET    。	   。* ↑ PA7
         ;	PD0  ↓* 。	   。    ICP
         ;	PD1  ↓* 。	   。    ALE
         ;	PD2  ↓* 。	   。    OC1B
         ;	PD3  ↓* 。	   。* ↑ PC7
         ;       PD4  ↓* 。	   。* ↑ PC6
         ;	PD5  ↓* 。	   。* ↑ PC5
         ;       PD6  ↓* 。	   。* ↑ PC4
         ;       PD7  ↓* 。	   。* ↑ PC3
         ;	XTAL2    。	   。* ↑ PC2
         ;	XTAL1    。	   。* ↑ PC1   
         ;	 GND     。20   21 。* ↓ PC0
         ;
         
          .include "8515def.inc"
         ;***************************************************************************
         ;* A P P L I C A T I O N   N O T E   F O R   T H E   A V R   F A M I L Y
         ;* 
         ;* Number		:AVR000
         ;* File Name		:"8515def.inc"
         ;* Title		:Register/Bit Definitions for the AT90S8515
         ;* Date                 :99.01.28
         ;* Version              :1.30
         ;* Support telephone	:+47 72 88 43 88 (ATMEL Norway)
         ;* Support fax		:+47 72 88 43 99 (ATMEL Norway)
         ;* Support E-mail	:avr@atmel.com
         ;* Target MCU		:AT90S8515
         ;*
         ;* DESCRIPTION
         ;* When including this file in the assembly program file, all I/O register	
         ;* names and I/O register bit names appearing in the data book can be used.
         ;* In addition, the six registers forming the three data pointers X, Y and
         ;* Z have been assigned names XL - ZH. Highest RAM address for Internal 
         ;* SRAM is also defined 
         ;*
         ;* The Register names are represented by their hexadecimal address.
         ;* 
         ;* The Register Bit names are represented by their bit number (0-7).
         ;* 
         ;* Please observe the difference in using the bit names with instructions
         ;* such as "sbr"/"cbr" (set/clear bit in register) and "sbrs"/"sbrc" 
         ;* (skip if bit in register set/cleared). The following example illustrates
         ;* this:
         ;* 
         ;* in	r16,PORTB		;read PORTB latch
         ;* sbr	r16,(1<<PB6)+(1<<PB5)	;set PB6 and PB5 (use masks, not bit#)
         ;* out  PORTB,r16		;output to PORTB
         ;*
         ;* in	r16,TIFR		;read the Timer Interrupt Flag Register
         ;* sbrc	r16,TOV0		;test the overflow flag (use bit#)
         ;* rjmp	TOV0_is_set		;jump if set
         ;* ...				;otherwise do something else
         ;***************************************************************************
         
         ;***** Specify Device
          .device AT90S8515
         
         ;***** I/O Register Definitions
          .equ	SREG	=$3f
          .equ	SPH	=$3e
          .equ	SPL	=$3d
          .equ	GIMSK	=$3b
          .equ	GIFR	=$3a
          .equ	TIMSK	=$39
          .equ	TIFR	=$38
          .equ	MCUCR	=$35
         
          .equ	TCCR0	=$33
          .equ	TCNT0	=$32
          .equ	OCR0	=$31
         
          .equ	TCCR1A	=$2f
          .equ	TCCR1B	=$2e
          .equ	TCNT1H	=$2d
          .equ	TCNT1L	=$2c
          .equ	OCR1AH	=$2b
          .equ	OCR1AL	=$2a
          .equ	OCR1BH	=$29
          .equ	OCR1BL	=$28
          .equ	ICR1H	=$25
          .equ	ICR1L	=$24
         
          .equ	WDTCR	=$21
          .equ	EEARH	=$1f
          .equ	EEARL	=$1e
          .equ	EEDR	=$1d
          .equ	EECR	=$1c
         
          .equ	PORTA	=$1b
          .equ	DDRA	=$1a
          .equ	PINA	=$19
          .equ	PORTB	=$18
          .equ	DDRB	=$17
          .equ	PINB	=$16
          .equ	PORTC	=$15
          .equ	DDRC	=$14
          .equ	PINC	=$13
          .equ	PORTD	=$12
          .equ	DDRD	=$11
          .equ	PIND	=$10
         
          .equ	SPDR	=$0f
          .equ	SPSR	=$0e
          .equ	SPCR	=$0d
          .equ	UDR	=$0c
          .equ	USR	=$0b
          .equ	UCR	=$0a
          .equ	UBRR	=$09
          .equ	ACSR	=$08
         
         
         ;***** Bit Definitions
          .equ	INT1	=7
          .equ	INT0	=6
         
          .equ	INTF1	=7
          .equ	INTF0	=6
         
          .equ	TOIE1	=7
          .equ	OCIE1A	=6
          .equ	OCIE1B	=5
          .equ	TICIE1	=3
          .equ	TOIE0	=1
         
          .equ	TOV1	=7
          .equ	OCF1A	=6
          .equ	OCF1B	=5
          .equ	ICF1	=3
          .equ	TOV0	=1
         
          .equ	SRE	=7
          .equ	SRW	=6
          .equ	SE	=5
          .equ	SM	=4
          .equ	ISC11	=3
          .equ	ISC10	=2
          .equ	ISC01	=1
          .equ	ISC00	=0
         
          .equ	CS02	=2
          .equ	CS01	=1
          .equ	CS00	=0
         
          .equ	COM1A1	=7
          .equ	COM1A0	=6
          .equ	COM1B1	=5
          .equ	COM1B0	=4
          .equ	PWM11	=1
          .equ	PWM10	=0
         
          .equ	ICNC1	=7
          .equ	ICES1	=6
          .equ	CTC1	=3
          .equ	CS12	=2
          .equ	CS11	=1
          .equ	CS10	=0
         
          .equ	WDDE	=4
          .equ	WDE	=3
          .equ	WDP2	=2
          .equ	WDP1	=1
          .equ	WDP0	=0
         
          .equ	EEMWE	=2
          .equ	EEWE	=1
          .equ	EERE	=0
         
          .equ	PA7	=7
          .equ	PA6	=6
          .equ	PA5	=5
          .equ	PA4	=4
          .equ	PA3	=3
          .equ	PA2	=2
          .equ	PA1	=1
          .equ	PA0	=0
         
          .equ	DDA7	=7
          .equ	DDA6	=6
          .equ	DDA5	=5
          .equ	DDA4	=4
          .equ	DDA3	=3
          .equ	DDA2	=2
          .equ	DDA1	=1
          .equ	DDA0	=0
         
          .equ	PINA7	=7
          .equ	PINA6	=6
          .equ	PINA5	=5
          .equ	PINA4	=4
          .equ	PINA3	=3
          .equ	PINA2	=2
          .equ	PINA1	=1
          .equ	PINA0	=0
         
          .equ	PB7	=7
          .equ	PB6	=6
          .equ	PB5	=5
          .equ	PB4	=4
          .equ	PB3	=3
          .equ	PB2	=2
          .equ	PB1	=1
          .equ	PB0	=0
         
          .equ	DDB7	=7
          .equ	DDB6	=6
          .equ	DDB5	=5
          .equ	DDB4	=4
          .equ	DDB3	=3
          .equ	DDB2	=2
          .equ	DDB1	=1
          .equ	DDB0	=0
         
          .equ	PINB7	=7
          .equ	PINB6	=6
          .equ	PINB5	=5
          .equ	PINB4	=4
          .equ	PINB3	=3
          .equ	PINB2	=2
          .equ	PINB1	=1
          .equ	PINB0	=0
         
          .equ	PC7	=7
          .equ	PC6	=6
          .equ	PC5	=5
          .equ	PC4	=4
          .equ	PC3	=3
          .equ	PC2	=2
          .equ	PC1	=1
          .equ	PC0	=0
         
          .equ	DDC7	=7
          .equ	DDC6	=6
          .equ	DDC5	=5
          .equ	DDC4	=4
          .equ	DDC3	=3
          .equ	DDC2	=2
          .equ	DDC1	=1
          .equ	DDC0	=0
         
          .equ	PINC7	=7
          .equ	PINC6	=6
          .equ	PINC5	=5
          .equ	PINC4	=4
          .equ	PINC3	=3
          .equ	PINC2	=2
          .equ	PINC1	=1
          .equ	PINC0	=0
         
          .equ	PD7	=7
          .equ	PD6	=6
          .equ	PD5	=5
          .equ	PD4	=4
          .equ	PD3	=3
          .equ	PD2	=2
          .equ	PD1	=1
          .equ	PD0	=0
         
          .equ	DDD7	=7
          .equ	DDD6	=6
          .equ	DDD5	=5
          .equ	DDD4	=4
          .equ	DDD3	=3
          .equ	DDD2	=2
          .equ	DDD1	=1
          .equ	DDD0	=0
         
          .equ	PIND7	=7
          .equ	PIND6	=6
          .equ	PIND5	=5
          .equ	PIND4	=4
          .equ	PIND3	=3
          .equ	PIND2	=2
          .equ	PIND1	=1
          .equ	PIND0	=0
         
          .equ	SPIE	=7
          .equ	SPE	=6
          .equ	DORD	=5
          .equ	MSTR	=4
          .equ	CPOL	=3
          .equ	CPHA	=2
          .equ	SPR1	=1
          .equ	SPR0	=0
         
          .equ	SPIF	=7
          .equ	WCOL	=6
         
          .equ	RXC	=7
          .equ	TXC	=6
          .equ	UDRE	=5
          .equ	FE	=4
          .equ	OR	=3
         
          .equ	RXCIE	=7
          .equ	TXCIE	=6
          .equ	UDRIE	=5
          .equ	RXEN	=4
          .equ	TXEN	=3
          .equ	CHR9	=2
          .equ	RXB8	=1
          .equ	TXB8	=0
         
          .equ	ACD	=7
          .equ	ACO	=5
          .equ	ACI	=4
          .equ	ACIE	=3
          .equ	ACIC	=2
          .equ	ACIS1	=1
          .equ	ACIS0	=0
         
          .def	XL	=r26
          .def	XH	=r27
          .def	YL	=r28
          .def	YH	=r29
          .def	ZL	=r30
          .def	ZH	=r31
         
          .equ 	RAMEND  =$25F	;Last On-Chip SRAM Location
          .equ	XRAMEND =$FFFF
          .equ	E2END	=$1FF
          .equ	FLASHEND=$FFF
         
         
          .equ	INT0addr=$001	;External Interrupt0 Vector Address
          .equ	INT1addr=$002	;External Interrupt1 Vector Address
          .equ	ICP1addr=$003	;Input Capture1 Interrupt Vector Address
          .equ	OC1Aaddr=$004	;Output Compare1A Interrupt Vector Address
          .equ	OC1Baddr=$005	;Output Compare1B Interrupt Vector Address
          .equ	OVF1addr=$006	;Overflow1 Interrupt Vector Address
          .equ	OVF0addr=$007	;Overflow0 Interrupt Vector Address
          .equ	SPIaddr =$008	;SPI Interrupt Vector Address
          .equ	URXCaddr=$009	;UART Receive Complete Interrupt Vector Address
          .equ	UDREaddr=$00a	;UART Data Register Empty Interrupt Vector Address
          .equ	UTXCaddr=$00b	;UART Transmit Complete Interrupt Vector Address
          .equ	ACIaddr =$00c	;Analog Comparator Interrupt Vector Address
000000 c00c      	rjmp	RESET		;Reset Handle
          .org  $00d
00000d e50f      RESET:       	LDI	R16,$5F		;必须先设堆栈,因为复位后SPL=0X00,SPH=0X00
00000e bf0d      	        OUT	SPL,R16		;AVR进堆栈是-1,出栈时+1,与MCS-51进出栈方向相反
00000f e002      	        LDI	R16,$02		;
000010 bf0e      	        OUT	SPH,R16		;设堆栈底为$025F,为AVR AT90S8515内部SRAM($0060-$025F底
         
                      
000011 ef0f      	     LDI r16,0XFF	;
000012 bb07      	     OUT DDRB,R16	;设方向寄存器为输出
000013 bb01                   OUT DDRD,R16
000014 bb0a                   out ddra,r16
000015 bb04                   out ddrc,r16 
         
000016 bb02                   out portd,r16	;关D口,硬件设定高电平LED关
000017 bb08                   out portb,r16	;关B口,硬件设定高电平LED关
000018 bb0b                   out porta,r16	;关A口,硬件设定高电平LED关
000019 bb05                   out portc,r16	;关C口,硬件设定高电平LED关
         
         
00001a e0c8      st:          ldi r28,0x08  	;循环次数       	
                      
          startb:      
00001b e018                   ldi R17,0x08
00001c ef2e                   ldi r18,0xfe	;0b1111 1110
00001d bb28      loopb:       out portb,r18	;开b口.0位LED灯亮,如何修改使2个或3个或1隔1等LED灯亮移位
00001e 9408                   sec		;置进位标志C=1
00001f 1f22                   rol r18		;通过进位左循环
000020 2fdc                   mov r29,r28	;移位(延时)次数
000021 d024                   rcall  delay	;调用延时子程序
000022 951a                   dec r17		;
000023 f7c9                   brne loopb		;R17不为0转,为0顺执
000024 bb08                   out portb,r16	;关B口
         
                      
000025 e018      startd:      ldi R17,0x08
000026 ef2e                   ldi r18,0xfe	;0b1111 1110
000027 bb22      loopd:       out portd,r18	;开d口.0位LED灯亮
000028 9408                   sec		;C=1
000029 1f22                   rol r18		;通过进位左循环
00002a 2fdc                   mov r29,r28
00002b d01a                   rcall  delay
00002c 951a                   dec r17
00002d f7c9                   brne loopd
00002e bb02                   out portd,r16
         
         
00002f e018      startc:      ldi R17,0x08
000030 ef2e                   ldi r18,0xfe	;0b1111 1110
000031 bb25      loopc:       out portc,r18	;开c口.0位LED灯亮
000032 9408                   sec
000033 1f22                   rol r18		;通过进位右循环
000034 2fdc                   mov r29,r28
000035 d010                   rcall  delay
000036 951a                   dec r17
000037 f7c9                   brne loopc
000038 bb05                   out portc,r16
         
         
000039 e018      starta:      ldi R17,0x08
00003a e72f                   ldi r18,0x7f	;0b0111 1111
00003b bb2b      loopa:       out porta,r18	;开a口.7位LED灯亮
00003c 9408                   sec
00003d 9527                   ror r18		;通过进位左循环
00003e 2fdc                   mov r29,r28
00003f d006                   rcall  delay
000040 951a                   dec r17
000041 f7c9                   brne loopa
000042 bb0b                   out porta,r16	;关a口
000043 95ca                   dec r28
                      
000044 f2a9                   breq  st 		;r28为0转
            
000045 cfd5                   rjmp  startb	;循环
         
         
         
000046 e2f3      delay:       ldi r31,0x23 	;延时子程序,可修改时间常数
000047 95ea      delay1:      dec r30          
000048 f7f1                   brne delay1
000049 95fa                   dec r31
00004a f7e1                   brne delay1
00004b 95da                   dec r29		;移位速度次数
00004c f7c9                   brne delay
00004d 9508                   ret		;子程序返回
         
         

Assembly complete with no errors.

⌨️ 快捷键说明

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