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

📄 asmavr.lst

📁 ATMEL AVR 单片机开发套件和大量C和ASM代码工程
💻 LST
📖 第 1 页 / 共 2 页
字号:
          .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
         ;***** 引脚定义
          .equ	Data=2	      ;数据
          .equ	Clk=3	      ;时钟
          .equ	Cs=4          ;片选 
          .equ    Key=1         ;键盘
         ;***** 全局寄存器变量
          .def	bitcnt=R16    ;位计数器
          .def	temp=R17		
          .def    temp1=r18 
          .def    temp2=r19
          .cseg
          .org 0
000000 c02a      rjmp reset
         ;**************************************
         ;     发送子程序,发送字节存放在temp中
         ;**************************************
000001 e008      send:   ldi    	bitcnt,$08
000002 98ac            	cbi    	PORTC,Cs 
000003 d06e            	rcall  	d90us	
000004 0f11      again:  lsl    	temp
000005 f410            	brcc   	COP
000006 9aaa            	sbi    	PORTC,Data
000007 c001            	rjmp  	next
000008 98aa      COP:  	cbi 	PORTC,Data
000009 0000      next: 	nop
00000a 0000            	nop
00000b 9aab            	sbi 	PORTC,Clk
00000c d061            	rcall 	d10us
00000d 98ab            	cbi 	PORTC,Clk
00000e d05f            	rcall	d10us
00000f 950a            	dec	bitcnt
000010 f799            	brne	again
000011 98aa            	cbi	PORTC,Data
000012 9508            	ret
         
         
         ;*****************************************
         ;        接收子程,接收字节存放temp2
         ;*****************************************
000013 e008      receive:ldi	bitcnt,$08
000014 98a2              cbi	DDRC,Data
000015 d05c      	rcall 	d90us
000016 0000              nop 
000017 9aab      loop1:  sbi	PORTC,Clk
000018 d055          	rcall 	d10us
000019 999a              sbic 	PINC,Data     
00001a c006              rjmp	plus                
00001b 9488              clc 
00001c 1f33        	rol 	temp2         
00001d 0000             	nop
00001e 98ab              cbi  	PORTC,Clk
00001f d04e           	rcall	d10us
000020 c005        	rjmp	last 
000021 9408      plus: 	sec
000022 1f33              rol	temp2
000023 0000          	nop
000024 98ab              cbi 	PORTC,Clk
000025 d048             	rcall  	d10us             
000026 950a      last:   dec	bitcnt
000027 f009              breq  	loop2
000028 cfee      	rjmp  	loop1
000029 9aa2      loop2:	sbi	ddrc,Data
00002a 9508              ret
           
         ;********** 程序由此执行*********************
         
00002b e51f      reset:   ldi 	temp,low(RAMEND)
00002c bf1d               out  	SPL,temp
00002d e012               ldi	temp,high(RAMEND)
00002e bf1e               out 	SPH,temp
00002f e11c               ldi	temp,$1c
000030 bb14               out	DDRC,temp
000031 e110               ldi    temp,$10
000032 bb15               out	PORTC,temp 
000033 e31c               ldi 	temp,60
000034 d041               rcall	delay_ms        ;初次启动延时30ms
000035 eb1f               ldi    temp,$bf
000036 dfca               rcall 	send
000037 9aac               sbi    PORTC,Cs
000038 e006               ldi	bitcnt,6
000039 ec18      wait_1:  ldi    temp,200
00003a d03b               rcall	delay_ms 
00003b 950a      	 dec	bitcnt
00003c f7e1       	 brne	wait_1
00003d ea14               ldi	temp,$a4         
00003e dfc2               rcall  send
00003f 9aac               sbi	PORTC,Cs
000040 e918               ldi	temp,$98
000041 dfbf               rcall	send
000042 ef1f      	 ldi 	temp,$ff
000043 dfbd               rcall	send
000044 9aac      	 sbi	PORTC,Cs
000045 e818               ldi	temp,$88
000046 dfba               rcall	send
000047 ef1e      	 ldi 	temp,$fe
000048 dfb8               rcall	send
000049 9aac      	 sbi	PORTC,Cs
00004a e910               ldi	temp,$90
00004b dfb5               rcall	send
00004c e018      	 ldi 	temp,$08
00004d dfb3               rcall	send
00004e 9aac      	 sbi	PORTC,Cs
          key_wait:         
00004f e11c               ldi 	temp,$1c
000050 bb14               out    DDRC,temp
000051 e110               ldi	temp,$10
000052 bb15               out	PORTC,temp
000053 9999      	 sbic 	PINC,Key       
000054 cffa               rjmp 	key_wait 
000055 e115               ldi 	temp,$15           ;read keypad
000056 dfaa               rcall 	send
000057 dfbb               rcall 	receive           
000058 9aac               sbi 	PORTC,Cs           
000059 ea11               ldi    temp,$a1
00005a dfa6               rcall	send
00005b 9aac               sbi    PORTC,Cs
00005c ea11               ldi    temp,$a1
00005d dfa3               rcall	send
00005e 9aac               sbi    PORTC,Cs
00005f ec18      	 ldi 	temp,$c8
000060 dfa0               rcall	send
000061 2f13               mov    temp,temp2
000062 df9e               rcall	send
000063 9aac               sbi	PORTC,Cs
000064 9532               swap	temp2
000065 703f      	 andi	temp2,$0f 
000066 ec19               ldi 	temp,$c9
000067 df99               rcall	send
000068 2f13               mov    temp,temp2
000069 df97               rcall	send
00006a 9aac               sbi	PORTC,Cs         
00006b 9b99      ss:	 sbis	PINC,key
00006c cffe               rjmp	ss
00006d cfe1               rjmp   key_wait
         
         ;*********************************************************
         ;                  延时子程序
         ;*********************************************************
         		
00006e e12a      d10us:  ldi	temp1,26
00006f 952a      lp:     dec	temp1
000070 f7f1             	brne	lp
000071 9508            	ret    
000072 ee2e      d90us:  ldi	temp1,238
000073 952a      lp1:    dec	temp1
000074 f7f1              brne	lp1
000075 9508              ret
         ;*********************************************************
         ;                ms级延时程序,延时(temp)ms     
         ;*********************************************************    
          delay_ms:
000076 e03b      	ldi	temp2,11
          lp2:
000077 dffa              rcall	d90us
000078 953a              dec	temp2
000079 f7e9              brne    lp2
00007a 951a              dec	temp
00007b f7d1              brne	delay_ms
00007c 9508      	ret          
         
         

Assembly complete with no errors.

⌨️ 快捷键说明

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