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

📄 hzmmi.s

📁 atmel的atmega128外扩ram对液晶的驱动调试程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module hzmmi.c
	.area text(rom, con, rel)
	.dbfile D:\美来尼尔\美兰尼尔改进\测控单元\面板程序\测控面板调试程序\hzmmi.c
	.dbfunc s main _main fI
;             pt -> <dead>
;              j -> <dead>
;              i -> <dead>
	.even
_main::
	.dbline -1
	.dbline 38
; #include "hzmmi.h"
; 
; #define __main__
; 
; #define T_RELOAD	(10000-1)		//1.000ms @10MHz,毫秒定时器用
; 
; void init1(void);                               //初始化子程序
; void run_1s(void);		                //1秒任务
; void dlyms(word ms);                           //毫秒级延时函数
; void delly(word ns);                           //毫秒级延时函数
; void str_hz(byte row,byte col,byte *str);     //显示汉字串及大ASCII串
; void wait_disp(void);                          //液晶忙等待
; void write_order(byte order);    //对液晶发送命令码
; void write_data(byte data);    //向LCD送数据码(ASCII码)
; void init_disp_nocls(void);   //对液晶初始化,不清屏
; void cls(void);               //清屏
; void init_disp(void);         //对液晶初始化,清屏
; void str_sasc(byte row,byte col,byte *str);     //显示小ASCII串
; void disp_face(void);             //显示首页
; void full(void);
; void write_data(byte data);
; void write_data_auto(byte data);
; 
; void wait_disp_auto(void);
; 
; word  sec_num;	   				//1秒任务计时器
; word  mstimer1;	   				//毫秒延时计数						     
; word  mstimer3;	   				//串口发送延时						     
; byte ctl_data;
; LIB_ADDR lib_addr;                              
; 
; 
; byte disp_buffer[128];            //显示缓冲区
; byte flag;
; 
; //主程序调用了上电复位进程,键盘进程,事件进程;
; void main(void)
; {
	.dbline 42
; word i,j;
; byte *pt;
; 
; 	flag=1;
	ldi R24,1
	sts _flag,R24
	.dbline 43
;         init1(); 		
	xcall _init1
	.dbline 44
;         init_disp();  
	xcall _init_disp
	.dbline 45
;         disp_face();
	xcall _disp_face
	.dbline 47
L6:
	.dbline 47
; //        dlyms(4000);
;         for(;;){
	.dbline 48
;           if(sec_num>1000)   {
	ldi R24,1000
	ldi R25,3
	lds R3,_sec_num+1
	lds R2,_sec_num
	cp R24,R2
	cpc R25,R3
	brsh L10
	.dbline 48
	.dbline 50
; 		
;               if(flag){
	lds R2,_flag
	tst R2
	breq L12
	.dbline 50
	.dbline 51
;                 flag=0;		
	clr R2
	sts _flag,R2
	.dbline 52
;                 disp_face();                         
	xcall _disp_face
	.dbline 53
; 			  }
	xjmp L13
L12:
	.dbline 54
;                else{
	.dbline 55
;                   flag=1;                 
	ldi R24,1
	sts _flag,R24
	.dbline 56
;                   cls();
	xcall _cls
	.dbline 57
; 			   }
L13:
	.dbline 59
; 		   
;              run_1s(); 
	xcall _run_1s
	.dbline 60
; 		  }
L10:
	.dbline 61
	wdr
	.dbline 62
	.dbline 47
	.dbline 47
	xjmp L6
X0:
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbsym l pt 1 pc
	.dbsym l j 1 s
	.dbsym l i 1 s
	.dbfunc s run_1s _run_1s fI
	.even
_run_1s::
	.dbline -1
	.dbline 66
;           asm("wdr");                     //软看门狗复位         
; 		}
; }
; //1秒任务
; void run_1s(void)
; {
	.dbline 67
;     sec_num=0;
	clr R2
	clr R3
	sts _sec_num+1,R3
	sts _sec_num,R2
	.dbline 68
;     PORTE^=RUN_LAMP;       
	ldi R24,4
	in R2,0x3
	eor R2,R24
	out 0x3,R2
	.dbline 69
;     PORTG|=EL_ON;
	lds R24,101
	ori R24,16
	sts 101,R24
	.dbline -2
	.dbline 70
; }
L14:
	.dbline 0 ; func end
	ret
	.dbfunc s init1 _init1 fI
	.even
_init1::
	.dbline -1
	.dbline 73
; //初始化
; void init1(void)
; {
	.dbline 75
; //定时器初始化
; 	MCUCR=0x80;//enable the External Memory
	ldi R24,128
	out 0x35,R24
	.dbline 76
; 	XMCRA=0x0e;
	ldi R24,14
	sts 109,R24
	.dbline 77
; 	XMCRB=0x80;
	ldi R24,128
	sts 108,R24
	.dbline 79
; 	
; 	TCCR1A=0;
	clr R2
	out 0x2f,R2
	.dbline 80
; 	TCCR1B=0x09;			        // ctc1=1,ck/1
	ldi R24,9
	out 0x2e,R24
	.dbline 81
; 	TIMSK=0x10;				// TIME1B COMPEAR INT OK
	ldi R24,16
	out 0x37,R24
	.dbline 82
; 	OCR1AH=(byte)(T_RELOAD/256);
	ldi R24,39
	out 0x2b,R24
	.dbline 83
; 	OCR1AL=(byte)T_RELOAD;
	ldi R24,15
	out 0x2a,R24
	.dbline 85
; //液晶口初始化	
; 	DDRB=0x00;              //键盘输入
	out 0x17,R2
	.dbline 86
;         DDRD=0xff;              //LCD控制
	ldi R24,255
	out 0x11,R24
	.dbline 87
;         DDRE=0x0f;      
	ldi R24,15
	out 0x2,R24
	.dbline 88
;         DDRF=0x0f;              //LIB为输出
	sts 97,R24
	.dbline 89
;         DDRG=0x18;          
	ldi R24,24
	sts 100,R24
	.dbline 91
; 
; 	asm("sei");	
	sei
	.dbline -2
	.dbline 92
; }
L15:
	.dbline 0 ; func end
	ret
	.area vector(rom, abs)
	.org 48
	jmp _int_timer0
	.area text(rom, con, rel)
	.dbfile D:\美来尼尔\美兰尼尔改进\测控单元\面板程序\测控面板调试程序\hzmmi.c
	.dbfunc s int_timer0 _int_timer0 fI
	.even
_int_timer0::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 96
; 
; #pragma interrupt_handler	int_timer0:13             //定义中断向量
; void int_timer0(void)                                     //定时器延时器中断,1ms中断一次
; {
	.dbline 97
; 	asm("cli");			//关中断
	cli
	.dbline 98
; 	OCR1AH=(byte)(T_RELOAD/256);
	ldi R24,39
	out 0x2b,R24
	.dbline 99
; 	OCR1AL=(byte)T_RELOAD;
	ldi R24,15
	out 0x2a,R24
	.dbline 100
;         sec_num++;                      //秒计时+1  	
	lds R25,_sec_num+1
	lds R24,_sec_num
	adiw R24,1
	sts _sec_num+1,R25
	sts _sec_num,R24
	.dbline 101
;         if(mstimer1>0) mstimer1--;
	lds R3,_mstimer1+1
	lds R2,_mstimer1
	tst R2
	brne X1
	tst R3
	breq L17
X1:
	.dbline 101
	movw R24,R2
	sbiw R24,1
	sts _mstimer1+1,R25
	sts _mstimer1,R24
L17:
	.dbline 103
; //        if(mstimer2>0) mstimer2--;
; 	asm("sei");				//中断允许
	sei
	.dbline -2
	.dbline 104
; }
L16:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbfunc s disp_face _disp_face fI
;              i -> <dead>
	.even
_disp_face::
	sbiw R28,2
	.dbline -1
	.dbline 107
; 
; void disp_face(void)
; {
	.dbline 109
; byte i;
; 	cls();
	xcall _cls
	.dbline 111
; 
;     strcpy(disp_buffer,"靶靶靶靶靶靶靶靶靶靶靶靶");
	ldi R18,<L20
	ldi R19,>L20
	ldi R16,<_disp_buffer
	ldi R17,>_disp_buffer
	xcall _strcpy
	.dbline 112
;     str_hz(0,0,disp_buffer);	
	ldi R24,<_disp_buffer
	ldi R25,>_disp_buffer
	std y+0,R24
	std y+1,R25
	clr R18
	clr R16
	xcall _str_hz
	.dbline 114
; 
;     strcpy(disp_buffer,"啊啊啊阿阿阿埃123456");
	ldi R18,<L21
	ldi R19,>L21
	ldi R16,<_disp_buffer
	ldi R17,>_disp_buffer
	xcall _strcpy
	.dbline 115
;     str_hz(16,0,disp_buffer);	
	ldi R24,<_disp_buffer
	ldi R25,>_disp_buffer
	std y+0,R24
	std y+1,R25
	clr R18
	ldi R16,16
	xcall _str_hz
	.dbline 117
; 		
;     strcpy(disp_buffer,"靶把耙班搬办绊绑棒磅");
	ldi R18,<L22
	ldi R19,>L22
	ldi R16,<_disp_buffer
	ldi R17,>_disp_buffer
	xcall _strcpy
	.dbline 118
;     str_hz(32,0,disp_buffer);		
	ldi R24,<_disp_buffer
	ldi R25,>_disp_buffer
	std y+0,R24
	std y+1,R25
	clr R18
	ldi R16,32
	xcall _str_hz
	.dbline 120
; 	
;     strcpy(disp_buffer,"01234567890123456789");
	ldi R18,<L23
	ldi R19,>L23
	ldi R16,<_disp_buffer
	ldi R17,>_disp_buffer
	xcall _strcpy
	.dbline 121
;     str_sasc(48,0,disp_buffer);				
	ldi R24,<_disp_buffer
	ldi R25,>_disp_buffer
	std y+0,R24
	std y+1,R25
	clr R18
	ldi R16,48
	xcall _str_sasc
	.dbline -2
	.dbline 122
; }
L19:
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbsym l i 3 c
	.dbfunc s dlyms _dlyms fI
;             ms -> R16,R17
	.even
_dlyms::
	.dbline -1
	.dbline 129
; 
; 
; 
; 
; //毫秒级延时函数
; void dlyms(word ms)
; {
	.dbline 130
; 	mstimer1=ms;
	sts _mstimer1+1,R17
	sts _mstimer1,R16
	xjmp L26
L25:
	.dbline 131
	.dbline 132
	wdr
	.dbline 134
L26:
	.dbline 131
; 	while(mstimer1){
	lds R3,_mstimer1+1
	lds R2,_mstimer1
	tst R2
	brne L25
	tst R3
	brne L25
	.dbline -2
	.dbline 135
; 	   asm("wdr");                     //软看门狗复位
; //           PORTB^=WDG;                     //硬看门狗复位
; 		   }
; }
L24:
	.dbline 0 ; func end
	ret
	.dbsym r ms 16 s
	.dbfunc s delly _delly fI
;              i -> R20
;             ns -> R16,R17
	.even
_delly::
	xcall push_gset1
	.dbline -1
	.dbline 138
; //延时函数
; void delly(word ns)
; {
	.dbline 140
	clr R20
	xjmp L32
L29:
	.dbline 140
	.dbline 141
	wdr
	.dbline 143
L30:
	.dbline 140
	inc R20
L32:
	.dbline 140
; byte i;
; 	for(i=0;i<ns;i++){
	mov R2,R20
	clr R3
	cp R2,R16
	cpc R3,R17
	brlo L29
	.dbline -2
	.dbline 144
; 	       asm("wdr");                     //软看门狗复位
; //           PORTB^=WDG;                     //硬看门狗复位
;            }
; }
L28:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r ns 16 s
	.dbfunc s wait_disp _wait_disp fI
;           flag -> R16
	.even
_wait_disp::
	.dbline -1
	.dbline 148
; 
; //液晶忙等待
; void wait_disp(void)
; {
	.dbline 151
; byte flag;
; 	
;         PORTD|=LCD_ID;               //CD=1	
	sbi 0x12,6
	.dbline 152
; 	PORTD|=LCD_ID;               //CD=1        	
	sbi 0x12,6
	.dbline 153
; 	PORTD&=~LCD_CS;           //CE=0
	cbi 0x12,5
	.dbline 154
; 	PORTD&=~LCD_CS;           //CE=0
	cbi 0x12,5
	.dbline 155
; 	PORTD&=~LCD_CS;           //CE=0		
	cbi 0x12,5
	.dbline 157
; 	
; 	for(;;)
L34:
	.dbline 158
; 	{	                
	.dbline 159
; 	        asm("nop");
	nop
	.dbline 160
; 	        asm("nop");
	nop
	.dbline 161
;                 asm("nop");
	nop
	.dbline 163
; 	    
; 	        flag=*(byte*)0x8000;
	lds R16,32768
	.dbline 164
; 		if((flag & LCD_BUSY_S0) && (flag & LCD_BUSY_S1))     //判断液晶忙否?
	sbrs R16,0
	rjmp L38
	sbrs R16,1
	rjmp L38
	.dbline 165
; 		{  
	.dbline 167
; 	   	          	               	    
; 		    PORTD|=LCD_CS|LCD_ID;         //CE=1,ID=1
	in R24,0x12
	ori R24,96
	out 0x12,R24
	.dbline 168
; 		    PORTD|=LCD_CS|LCD_ID;         //CE=1,ID=1	
	in R24,0x12
	ori R24,96
	out 0x12,R24
	.dbline 169
; 		    return;
	xjmp L33
L38:
	.dbline 171
	nop
	.dbline 172
	nop
	.dbline 173
	nop
	.dbline 174
	.dbline 157
	.dbline 157
	xjmp L34
X2:
	.dbline -2
L33:
	.dbline 0 ; func end
	ret
	.dbsym r flag 16 c
	.dbfunc s write_order _write_order fI
;             pt -> <dead>
;          order -> R20
	.even
_write_order::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 179
; 		}	
; 		asm("nop");
; 		asm("nop");
; 		asm("nop");                  
; 	}	
; }
; 
; //对液晶发送命令码
; void write_order(byte order)//对液晶发送命令码
; {
	.dbline 182
; byte *pt; 
; 
;         wait_disp();
	xcall _wait_disp
	.dbline 183
;         PORTD|=LCD_ID;       //CD=1
	sbi 0x12,6
	.dbline 184
; 	PORTD|=LCD_ID;       //CD=1
	sbi 0x12,6
	.dbline 185
; 	PORTD|=LCD_ID;       //CD=1	
	sbi 0x12,6
	.dbline 186
; 	PORTD&=~LCD_CS;       //CS=0
	cbi 0x12,5
	.dbline 187
; 	PORTD&=~LCD_CS;       //CS=0
	cbi 0x12,5
	.dbline 188
; 	PORTD&=~LCD_CS;       //CS=0       
	cbi 0x12,5
	.dbline 189
; 	*(byte*)0x8000=order;              //命令码		
	sts 32768,R20
	.dbline 190
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline 191
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline 192
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline 193
; 	PORTD&=~LCD_ID;       //CD=0
	cbi 0x12,6
	.dbline 194
; 	PORTD&=~LCD_ID;       //CD=0
	cbi 0x12,6
	.dbline 195
; 	PORTD&=~LCD_ID;       //CD=0	
	cbi 0x12,6
	.dbline -2
	.dbline 196
; }
L40:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l pt 1 pc
	.dbsym r order 20 c
	.dbfunc s write_data _write_data fI
;             pt -> <dead>
;           data -> R20
	.even
_write_data::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 200
; 
; 
; void write_data(byte data)
; {
	.dbline 203
; byte *pt; 
; 
;         wait_disp();
	xcall _wait_disp
	.dbline 204
;         PORTD&=~LCD_ID;       //CD=0
	cbi 0x12,6
	.dbline 205
; 	PORTD&=~LCD_ID;       //CD=0
	cbi 0x12,6
	.dbline 206
; 	PORTD&=~LCD_ID;       //CD=0	
	cbi 0x12,6
	.dbline 207
; 	PORTD&=~LCD_CS;       //CS=0
	cbi 0x12,5
	.dbline 208
; 	PORTD&=~LCD_CS;       //CS=0
	cbi 0x12,5
	.dbline 209
; 	PORTD&=~LCD_CS;       //CS=0          
	cbi 0x12,5
	.dbline 210
; 	*(byte*)0x8000=data;              //命令码		
	sts 32768,R20
	.dbline 211
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline 212
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline 213
; 	PORTD|=LCD_CS;       //CS=1
	sbi 0x12,5
	.dbline -2
	.dbline 215
; 	
; }
L41:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l pt 1 pc
	.dbsym r data 20 c
	.dbfunc s cls _cls fI
;              i -> R20,R21
	.even
_cls::
	xcall push_gset1
	.dbline -1
	.dbline 219
; 
; //清屏
; void cls(void)
; {
	.dbline 222
; 	int i;
; 	
;         write_data(00);          //设置显示储存器首地址
	clr R16
	xcall _write_data
	.dbline 223
;         write_data(00);
	clr R16
	xcall _write_data
	.dbline 224
;         write_order(0x24);
	ldi R16,36
	xcall _write_order
	.dbline 225
;         write_order(0xb0);       //设置自动写方式
	ldi R16,176
	xcall _write_order
	.dbline 226
;         wait_disp();
	xcall _wait_disp
	.dbline 227
;     	for(i=0;i<8000;i++)     //8k显示存储器填00
	clr R20
	clr R21
L43:
	.dbline 228

⌨️ 快捷键说明

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