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

📄 lcd_init.s

📁 使用ICCAVR编写的mega128L单片机的12864液晶显示程序
💻 S
字号:
	.module lcd_init.c
	.area text(rom, con, rel)
	.dbfile E:\icc\lcd\lcd_init.c
	.dbfunc e delay _delay fV
;              n -> R16,R17
	.even
_delay::
	.dbline -1
	.dbline 40
; /*
; LCD12864液晶驱动模块
; */
; /*
; PG0---RS---4
; PG1---R/W--5
; PG2---EN---6    
; PA0---DB0---7
; PA1---DB1---8
; PA2---DB2---9
; PA3---DB3---10
; PA4---DB4---11
; PA5---DB5---12
; PA6---DB6---13
; PA7---DB7---14
; 
; */
; #include <iom128v.h>
; #include <macros.h> 
; 
; 
; /*命令或是数据选择*/
; /*RS = 0命令,RS = 1数据*/
; #define RS_CLR PORTG&=~(1<<PG0)  
; #define RS_SET PORTG|=(1<<PG0)   
; /*读取或写入选择*/
; /*RW = 1读,RW = 0写*/
; #define RW_CLR PORTG&=~(1<<PG1)
; #define RW_SET PORTG|=(1<<PG1)
; /*读写使能信号*/
; /*下降沿有效*/
; #define EN_CLR PORTG&=~(1<<PG2)
; #define EN_SET PORTG|=(1<<PG2)
; /*芯片复位脚*/
; /*高电平复位
; #define RST_CLR PORTD&=~(1<<PD7)
; #define RST_SET PORTD|=(1<<PD7)*/
; //延时函数
; void delay (unsigned int n)
; {
L2:
	.dbline 41
L3:
	.dbline 41
; while(n--);
	movw R2,R16
	subi R16,1
	sbci R17,0
	tst R2
	brne L2
	tst R3
	brne L2
X0:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r n 16 i
	.dbend
	.dbfunc e chk_busy _chk_busy fV
	.even
_chk_busy::
	.dbline -1
	.dbline 44
; }
; void chk_busy(void)
; {
	.dbline 45
;  PORTA=0XFF;
	ldi R24,255
	out 0x1b,R24
	.dbline 46
;  RS_CLR;
	lds R24,101
	andi R24,254
	sts 101,R24
	.dbline 47
;  RW_SET;
	lds R24,101
	ori R24,2
	sts 101,R24
	.dbline 49
;  
;  DDRA=0X00;
	clr R2
	out 0x1a,R2
	.dbline 51
;  
;  EN_SET;
	lds R24,101
	ori R24,4
	sts 101,R24
L6:
	.dbline 52
L7:
	.dbline 52
;  while(PINA&0X80);
	sbic 0x19,7
	rjmp L6
	.dbline 53
;  EN_CLR;
	lds R24,101
	andi R24,251
	sts 101,R24
	.dbline 54
;  DDRA=0XFF;
	ldi R24,255
	out 0x1a,R24
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_write_code _LCD_write_code fV
;           code -> R20
	.even
_LCD_write_code::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 58
; }
; //显示屏命令写入函数
; void LCD_write_code(unsigned char code)
; {
	.dbline 59
; chk_busy();
	xcall _chk_busy
	.dbline 60
; RS_CLR;
	lds R24,101
	andi R24,254
	sts 101,R24
	.dbline 61
; RW_CLR;
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 62
; PORTA=code;
	out 0x1b,R20
	.dbline 63
; EN_SET;
	lds R24,101
	ori R24,4
	sts 101,R24
	.dbline 64
; delay(100);
	ldi R16,100
	ldi R17,0
	xcall _delay
	.dbline 65
; EN_CLR;
	lds R24,101
	andi R24,251
	sts 101,R24
	.dbline -2
L9:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r code 20 c
	.dbend
	.dbfunc e LCD_write_data _LCD_write_data fV
;           data -> R20
	.even
_LCD_write_data::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 69
; }
; //显示屏数据显写入函数
; void LCD_write_data(unsigned char data)
; {
	.dbline 70
; chk_busy();
	xcall _chk_busy
	.dbline 71
; RS_SET;
	lds R24,101
	ori R24,1
	sts 101,R24
	.dbline 72
; RW_CLR;
	lds R24,101
	andi R24,253
	sts 101,R24
	.dbline 73
; PORTA=data;
	out 0x1b,R20
	.dbline 74
; EN_SET;
	lds R24,101
	ori R24,4
	sts 101,R24
	.dbline 75
; delay(100);
	ldi R16,100
	ldi R17,0
	xcall _delay
	.dbline 76
; EN_CLR; 
	lds R24,101
	andi R24,251
	sts 101,R24
	.dbline -2
L10:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e disp_char _disp_char fV
;           asii -> R20
;       position -> R22
	.even
_disp_char::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 80
; }
; /*单个字符输入函数;position--显示位置,data--显示内容*/
; void disp_char(unsigned char position,unsigned char asii)
; {
	.dbline 81
;  LCD_write_code(position);
	mov R16,R22
	xcall _LCD_write_code
	.dbline 82
;  LCD_write_data(asii);
	mov R16,R20
	xcall _LCD_write_data
	.dbline -2
L11:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r asii 20 c
	.dbsym r position 22 c
	.dbend
	.dbfunc e disp_word _disp_word fV
;           word -> R20,R21
;       position -> R22
	.even
_disp_word::
	xcall push_gset2
	movw R20,R18
	mov R22,R16
	.dbline -1
	.dbline 97
; }
; /*一串字符输入函数
; void disp_char_str(unsigned char position,unsigned char *str)
; {
;  LCD_write_code(position);
;  while(*str!=0)                    //含义???
;       {
; 	   
; 	   LCD_write_data(*str);
; 	   str++;
; 	  }
; }*/
; /*汉字输入*/
; void disp_word(unsigned char position,unsigned char *word)
; {
	.dbline 98
; LCD_write_code(position);//要显示的位置
	mov R16,R22
	xcall _LCD_write_code
	xjmp L14
L13:
	.dbline 100
	.dbline 101
	movw R30,R20
	ldd R16,z+0
	xcall _LCD_write_data
	.dbline 102
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 103
L14:
	.dbline 99
; while(*word!=0)
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L13
	.dbline -2
L12:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r word 20 pc
	.dbsym r position 22 c
	.dbend
	.dbfunc e disp_init _disp_init fV
	.even
_disp_init::
	.dbline -1
	.dbline 109
;      {
; 	  LCD_write_data(*word);
; 	  word++;
; 	 } 
;  
; }
; 
; //显示屏初始化
; void disp_init(void)
; {
	.dbline 110
; DDRA=0XFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 112
; //DDRD=(1<<PD4)|(1<<PD5)|(1<<PD6)|(1<<PD7);
; DDRG=0XFF;
	sts 100,R24
	.dbline 114
; 
; LCD_write_code(0x30);//功能设定/*30---基本指令动作
	ldi R16,48
	xcall _LCD_write_code
	.dbline 115
; LCD_write_code(0x01);//清屏,地址指针指向00H
	ldi R16,1
	xcall _LCD_write_code
	.dbline 116
; LCD_write_code(0x06);//光标的移动方向
	ldi R16,6
	xcall _LCD_write_code
	.dbline 117
; LCD_write_code(0x0c);//光标反白显示--0x0f/*开显示,关游标
	ldi R16,12
	xcall _LCD_write_code
	.dbline -2
L16:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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