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

📄 训练项目十一:led及拨码开关的综合实验.s

📁 长沙理工自己的实验程序
💻 S
字号:
	.module _训练项目十一:LED及拨码开关的综合实验.c
	.area text(rom, con, rel)
;   uidelay_time -> R20,R21
;         uitime -> R16,R17
	.even
_Delay::
	st -y,R20
	st -y,R21
; /*******************************************Copyright(c)*******************************************
; **                           ChangSha University of Science & Technology                   
; **
; **                                     http://www.csust.com                                       
; **
; **-------File Info---------------------------------------------------------------------------------
; ** File Name:                        LED及拨码开关的综合试实验
; ** Latest modified Date:             2008.7.26
; ** Latest Version:
; ** Description:                      通过控制方向寄存器来控制输出电平的高低,进而实现交互闪烁灯              
; **                            
; **-------------------------------------------------------------------------------------------------
; ** Created By:
; ** Created date:
; ** Version:
; ** Descriptions:
; **
; **-------------------------------------------------------------------------------------------------
; ** Modified by:                      congdongliang
; ** Modified date:                    2008.7.26
; ** Version:
; ** Description:                      根据《代码规范》修改了部分变量命名及程序格式,使程序更规范
; **                            
; **************************************************************************************************/             
; 
; #include "iom128v.h"
; 
; /**************************************************************************************************
; ** Function name:                    Delay
; ** Description:                      延时程序
; ** input parameters:         
; ** output parameters:         
; ** Returned value:            
; ** Created by:
; ** Created Date:
; **-------------------------------------------------------------------------------------------------
; ** Modified by:                      congdongliang
; ** Modified date:                    2008.7.26
; **-------------------------------------------------------------------------------------------------
; **************************************************************************************************/
; 
; void Delay (unsigned int  uitime)
; {                    
;     unsigned int uidelay_time;
; 	     
;     for(uidelay_time=0; uidelay_time<uitime; uidelay_time++);
	clr R20
	clr R21
	xjmp L5
L2:
L3:
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	cp R20,R16
	cpc R21,R17
	brlo L2
X0:
L1:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.even
_main::
;        
; }
; 
; /**************************************************************************************************
; ** Function name:                    main
; ** Description:                      通过控制寄存器来控制PA口输出电平的高低,来实现两个LED灯的交互
; **                                   闪烁                    
; ** input parameters:                 
; ** output parameters:               
; **
; ** Returned value:
; ** Created by:
; ** Created Date:
; **-------------------------------------------------------------------------------------------------
; ** Modified by:                      congdongliang
; ** Modified date:                    2008.7.26
; **-------------------------------------------------------------------------------------------------
; **************************************************************************************************/
; void main ()
; {
;     DDRA = 0xFF;              
	ldi R24,255
	out 0x1a,R24
;     PORTA= 0xFF;  
	out 0x1b,R24
;     DDRB = 0x00;
	clr R2
	out 0x17,R2
;     PORTB= 0xFF;                     /* 定义PA口、PB口的数据方向寄存器,以及对其数据寄存器初始化 */
	out 0x18,R24
; 	 
;     for(;;){
L7:
;         if((PINB & 0x01) == 0) {
	sbic 0x16,0
	rjmp L11
X1:
; 	        PORTA = 0xFD;            /* 判断PB0的状态,若为0,则执行LED交互闪烁                  */
	ldi R24,253
	out 0x1b,R24
; 	    
;             Delay(6000);
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	        Delay(6000);         
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	        Delay(6000);          
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000);         
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000);
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	   
;             PORTA = 0xFB;
	ldi R24,251
	out 0x1b,R24
; 	             
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	        Delay(6000);         
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	        Delay(6000);          
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000);
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000); 
	ldi R16,6000
	ldi R17,23
	xcall _Delay
; 	        Delay(6000);         
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;             Delay(6000);
	ldi R16,6000
	ldi R17,23
	xcall _Delay
;         }else{ 
	xjmp L7
L11:
;                        
;             PORTA = 0xFF;            /* PB0为1时,PA口输出全为1,LED全部不亮                     */         
	ldi R24,255
	out 0x1b,R24
;         }
; 	}
	xjmp L7
X2:
L6:
	.dbline 0 ; func end
	ret
; }
; /**************************************************************************************************
;   END FILE
; **************************************************************************************************/
; 

⌨️ 快捷键说明

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