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

📄 st7920iccavrmega8.s

📁 AVR学习开发 板
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module st7920iccavrmega8.c
	.area data(ram, con, rel)
_AC_TABLE::
	.blkb 2
	.area idata
	.byte 128,129
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 130,131
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 132,133
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 134,135
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 144,145
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 146,147
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 148,149
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 150,151
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 136,137
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 138,139
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 140,141
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 142,143
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 152,153
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 154,155
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 156,157
	.area data(ram, con, rel)
	.blkb 2
	.area idata
	.byte 158,159
	.area data(ram, con, rel)
	.dbfile E:\AVR学习专区\AVR学习板\st7920iccavrmega8.c
	.dbsym e AC_TABLE _AC_TABLE A[32:32]c
_str2::
	.blkb 17
	.area idata
	.byte 187,182,211,173,185,226,193,217,'A,'V,'R,'L,'C,'D,33,33
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\AVR学习专区\AVR学习板\st7920iccavrmega8.c
	.dbsym e str2 _str2 A[17:17]c
_str1::
	.blkb 65
	.area idata
	.byte 212,198,196,184,198,193,183,231,214,242,211,176,201,238,163,172
	.byte 179,164,186,211,189,165,194,228,207,254,208,199,179,193,161,163
	.byte 230,207,182,240,211,166,187,218,205,181,193,233,210,169,163,172
	.byte 177,204,186,163,199,224,204,236,210,185,210,185,208,196,161,163
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\AVR学习专区\AVR学习板\st7920iccavrmega8.c
	.dbsym e str1 _str1 A[65:65]c
	.area text(rom, con, rel)
	.dbfile E:\AVR学习专区\AVR学习板\st7920iccavrmega8.c
	.dbfunc e SendByte _SendByte fV
;              i -> R20
;          Dbyte -> R16
	.even
_SendByte::
	rcall push_gset1
	.dbline -1
	.dbline 41
; /****************************************************************************************
;            LCM(DM12864M-带字库,ST7920控制芯片)mega8控制显示程序   
; 		                                                
;              程序功能:该程序是用AVR来控制对DM12864M
; 			           读写信号等的操作.
;              硬件连接:采用串行方式显示,分配PB6=SID,PB7=SCK,PB1=LCD_ON
; 			           三个I/O口分别作为LCM数据,时钟信号,背光开关
; 					   的控制。
; 					   CS和/RESET直接接VCC;PSB直接接GND 
; 					                                 作者:张国旗
; 													 2008年12月29号       
; ****************************************************************************************/
; #include <iom8v.h>
; #include <macros.h>
; #include <stdio.h>
; 
; #define LCDDDR        DDRB
; #define LCDDDR_IN     LCDDDR&=~BIT(PB6);
; #define LCDDDR_OUT    LCDDDR|=BIT(PB1)|BIT(PB6)|BIT(PB7);
; /*===============================================================*/
; #define LCDCTL      PORTB   
; #define SID_ON      LCDCTL |= BIT(PB6)  //数据                            
; #define SID_OFF     LCDCTL &= ~BIT(PB6)  
; #define SCK_ON      LCDCTL |= BIT(PB7)  //时钟                          
; #define SCK_OFF     LCDCTL &= ~BIT(PB7) 
; #define LCD_ON      LCDCTL |= BIT(PB1)  //开启背光
; #define LCD_OFF     LCDCTL &= ~BIT(PB1)  
; //#define uchar unsigned char
; /***********************函数体部分*********************************/
; unsigned char  AC_TABLE[]={
; 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
; 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,
; 0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
; 0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
; };
; unsigned char  str2[]="欢迎光临AVRLCD!!";
; unsigned char  str1[]="云母屏风烛影深,长河渐落晓星沉。嫦娥应悔偷灵药,碧海青天夜夜心。";
; unsigned char  bmp1[];//先声明一下就可以把表放在函数后面啦,呵呵
; //=========发送一个字节程序=========
; void SendByte(unsigned char Dbyte)
; {
	.dbline 43
;     unsigned char i;
;     for(i=0;i<8;i++)
	clr R20
	rjmp L5
L2:
	.dbline 44
;  	{
	.dbline 45
;   	 	if(Dbyte&0x80)SID_ON;
	sbrs R16,7
	rjmp L6
	.dbline 45
	sbi 0x18,6
	rjmp L7
L6:
	.dbline 46
;   		else SID_OFF;
	cbi 0x18,6
L7:
	.dbline 47
	sbi 0x18,7
	.dbline 48
	cbi 0x18,7
	.dbline 49
	lsl R16
	.dbline 50
L3:
	.dbline 43
	inc R20
L5:
	.dbline 43
	cpi R20,8
	brlo L2
	.dbline -2
L1:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r Dbyte 16 c
	.dbend
	.dbfunc e ReceiveByte _ReceiveByte fc
;          temp2 -> R16
;          temp1 -> R18
;              i -> R20
	.even
_ReceiveByte::
	rcall push_gset1
	.dbline -1
	.dbline 54
;   		SCK_ON;
;   		SCK_OFF;
;   		Dbyte=Dbyte<<1;
;  	}
; }
; //接收一个字节程序((0xf0&temp1)+(0x0f&temp2))
; unsigned char ReceiveByte(void)  
; {
	.dbline 56
;     unsigned char i,temp1,temp2;
;     temp1=temp2=0;
	clr R16
	clr R18
	.dbline 57
;     for(i=0;i<8;i++)
	clr R20
	rjmp L12
L9:
	.dbline 58
;     {
	.dbline 59
; 	    LCDDDR_IN;
	cbi 0x17,6
	.dbline 59
	.dbline 60
; 		temp1=temp1<<1;
	lsl R18
	.dbline 61
;         if ((PINB&0x40)!=0)temp1++;  //与端口设置有关,主要修改端口时修改此位
	sbis 0x16,6
	rjmp L13
	.dbline 61
	inc R18
L13:
	.dbline 62
	in R24,0x17
	ori R24,194
	out 0x17,R24
	.dbline 62
	.dbline 63
	sbi 0x18,7
	.dbline 64
	cbi 0x18,7
	.dbline 65
L10:
	.dbline 57
	inc R20
L12:
	.dbline 57
	cpi R20,8
	brlo L9
	.dbline 66
;     	LCDDDR_OUT;
; 		SCK_ON;
;   		SCK_OFF;
;   	}
;     for(i=0;i<8;i++)
	clr R20
	rjmp L18
L15:
	.dbline 67
;     {
	.dbline 68
; 	    LCDDDR_IN;
	cbi 0x17,6
	.dbline 68
	.dbline 69
; 		temp2=temp2<<1;
	lsl R16
	.dbline 70
;         if ((PINB&0x40)!=0)temp2++;  //与端口设置有关,主要修改端口时修改此位
	sbis 0x16,6
	rjmp L19
	.dbline 70
	inc R16
L19:
	.dbline 71
	in R24,0x17
	ori R24,194
	out 0x17,R24
	.dbline 71
	.dbline 72
	sbi 0x18,7
	.dbline 73
	cbi 0x18,7
	.dbline 74
L16:
	.dbline 66
	inc R20
L18:
	.dbline 66
	cpi R20,8
	brlo L15
	.dbline 75
; 		LCDDDR_OUT;
; 		SCK_ON;
;   		SCK_OFF;
;     }
;         return ((0xf0&temp1)+(0x0f&temp2));
	mov R24,R16
	andi R24,15
	mov R16,R18
	andi R16,240
	add R16,R24
	.dbline -2
L8:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r temp2 16 c
	.dbsym r temp1 18 c
	.dbsym r i 20 c
	.dbend
	.dbfunc e CheckBusy _CheckBusy fV
	.even
_CheckBusy::
	.dbline -1
	.dbline 79
; }
; //液晶忙检查CheckBusy
; void CheckBusy( void )               
; {
L22:
	.dbline 80
;     do SendByte(0xfc);               //11111,RW(1),RS(0),0
	ldi R16,252
	rcall _SendByte
L23:
	.dbline 81
;     while(0x80&ReceiveByte());
	rcall _ReceiveByte
	sbrc R16,7
	rjmp L22
	.dbline -2
L21:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e WriteCommand _WriteCommand fV
;          Cbyte -> R20
	.even
_WriteCommand::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 85
; }
; //========写命令========
; void WriteCommand( unsigned char Cbyte )
; {
	.dbline 86
; 	CheckBusy();
	rcall _CheckBusy
	.dbline 87
;     SendByte(0xf8);           	    //11111,RW(0),RS(0),0
	ldi R16,248
	rcall _SendByte
	.dbline 88
;     SendByte(0xf0&Cbyte);
	mov R16,R20
	andi R16,240
	rcall _SendByte
	.dbline 89
;     SendByte(0xf0&Cbyte<<4);
	mov R16,R20
	andi R16,#0x0F
	swap R16
	andi R16,240
	rcall _SendByte
	.dbline -2
L25:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r Cbyte 20 c
	.dbend
	.dbfunc e WriteData _WriteData fV
;          Dbyte -> R20
	.even
_WriteData::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 93
; }
; //========写数据========
; void WriteData( unsigned char Dbyte )
; {
	.dbline 94
;     CheckBusy();
	rcall _CheckBusy
	.dbline 95
;     SendByte(0xfa);           		//11111,RW(0),RS(1),0
	ldi R16,250
	rcall _SendByte
	.dbline 96
;     SendByte(0xf0&Dbyte);
	mov R16,R20
	andi R16,240
	rcall _SendByte
	.dbline 97
;     SendByte(0xf0&Dbyte<<4);
	mov R16,R20
	andi R16,#0x0F
	swap R16
	andi R16,240
	rcall _SendByte
	.dbline -2
L26:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r Dbyte 20 c
	.dbend
	.dbfunc e ReadData _ReadData fc
	.even
_ReadData::
	.dbline -1
	.dbline 101
; }
; //========读数据========
; unsigned char ReadData( void )
; {
	.dbline 102
;     CheckBusy();
	rcall _CheckBusy
	.dbline 103
;     SendByte(0xfe);           		//11111,RW(1),RS(1),0
	ldi R16,254
	rcall _SendByte
	.dbline 104
;     return ReceiveByte();
	rcall _ReceiveByte
	.dbline -2
L27:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Delay _Delay fV
;            usn -> R20

⌨️ 快捷键说明

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