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

📄 lcd.s

📁 mega128的串口发送文件.可以发送0X55上位机使用串口调试工具就可以接收了.
💻 S
📖 第 1 页 / 共 2 页
字号:
	add R30,R24
	adc R31,R25
	lpm R16,Z
	xcall _SdData
	.dbline 114
L18:
	.dbline 110
	inc R14
L20:
	.dbline 110
	mov R24,R14
	cpi R24,8
	brlo L17
	.dbline 115
L14:
	.dbline 105
	inc R20
L16:
	.dbline 105
	cpi R20,2
	brsh X1
	xjmp L13
X1:
	.dbline -2
L12:
	xcall pop_gset5
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r j 14 c
	.dbsym r date 22 c
	.dbsym r n 10 c
	.dbsym r m 12 c
	.dbsym l page 10 c
	.dbend
	.dbfunc e SdPage _SdPage fV
;              i -> R20
;              j -> R22
	.even
_SdPage::
	xcall push_gset2
	.dbline -1
	.dbline 122
; 		   {
; 		   SdData(data_hi[j+8*i+8*2*date]);   //为什么要写两次呢?  0--7 +8*0  
;            SdData(data_hi[j+8*i+8*2*date]);  //                     0-7  +8*1
; 		   }
; 	   }
; }	   
; 
; //-------------------------------------------------------------------------------
; //清屏 
; //-------------------------------------------------------------------------------
; void SdPage(void)
;   {
	.dbline 124
;   UINT8 i, j; 	
;   SPCR = 0x50;
	ldi R24,80
	out 0xd,R24
	.dbline 125
;   for(i=0;i<12;i++)              // page data
	clr R20
	xjmp L25
L22:
	.dbline 126
;     {
	.dbline 127
; 	WDR();
	wdr
	.dbline 128
;     SdCmd(0xb0|i );              // select page
	mov R16,R20
	ori R16,176
	xcall _SdCmd
	.dbline 129
;     SdCmd(0x10);                 // column address start at 00 (Y7,Y6,Y5)
	ldi R16,16
	xcall _SdCmd
	.dbline 130
;     SdCmd(0x00);                 // column address start at 00 (Y4,Y3,Y2,Y1)
	clr R16
	xcall _SdCmd
	.dbline 131
;     for(j=0;j<128;j++)
	clr R22
	xjmp L29
L26:
	.dbline 132
	.dbline 133
	clr R16
	xcall _SdData
	.dbline 134
	clr R16
	xcall _SdData
	.dbline 135
L27:
	.dbline 131
	inc R22
L29:
	.dbline 131
	cpi R22,128
	brlo L26
	.dbline 136
L23:
	.dbline 125
	inc R20
L25:
	.dbline 125
	cpi R20,12
	brlo L22
	.dbline 137
;       {
;       SdData(0X00);	  		     //清屏 
;       SdData(0X00);
;       }
;    }			
;   SPCR = 0x54; 
	ldi R24,84
	out 0xd,R24
	.dbline -2
L21:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r j 22 c
	.dbend
	.dbfunc e test _test fV
;              i -> <dead>
;              j -> <dead>
;              k -> R20
;           page -> R22
;           data -> R20
	.even
_test::
	xcall push_gset2
	mov R22,R18
	mov R20,R16
	sbiw R28,3
	.dbline -1
	.dbline 141
;   }
; 
; void test(UINT8 data,UINT8 page)
; {
	.dbline 143
;    UINT8 k,j,i;
;    SPCR = 0x50;
	ldi R24,80
	out 0xd,R24
	.dbline 144
;    date[0]=(data&0xf0)>>4;
	mov R24,R20
	andi R24,240
	swap R24
	andi R24,#0x0F
	sts _date,R24
	.dbline 145
;    date[1]=data&0x0f;
	mov R24,R20
	andi R24,15
	sts _date+1,R24
	.dbline 147
;    
;    for(k=0;k<2;k++)
	clr R20
	xjmp L35
L32:
	.dbline 148
	.dbline 149
	ldi R24,<_date
	ldi R25,>_date
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	std y+2,R2
	ldi R24,8
	mul R24,R20
	mov R24,R0
	andi R24,15
	std y+0,R24
	mov R18,R20
	lsr R18
	subi R18,240    ; addi 16
	mov R16,R22
	xcall _LCDSHOW
	.dbline 150
L33:
	.dbline 147
	inc R20
L35:
	.dbline 147
	cpi R20,2
	brlo L32
	.dbline 151
; 	     {
; 		     LCDSHOW( page, 0x10+k/2, (0x08*k)&0x0f, date[k]);  
; 		}
;  SPCR = 0x54;		
	ldi R24,84
	out 0xd,R24
	.dbline -2
L30:
	adiw R28,3
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym l i 4 c
	.dbsym l j 4 c
	.dbsym r k 20 c
	.dbsym r page 22 c
	.dbsym r data 20 c
	.dbend
	.dbfunc e LCD_init_initialize _LCD_init_initialize fV
	.even
_LCD_init_initialize::
	xcall push_gset2
	.dbline -1
	.dbline 160
; }
; 
; 
; 
; //-------------------------------------------------------------------------------
; //LCD初始化
; //-------------------------------------------------------------------------------
; void LCD_init_initialize(void)
;  {
	.dbline 161
; 	LCD_control&=~(1<<LCD_RST);      // reset the LCD module
	cbi 0x12,5
	.dbline 162
;     delayms(5);
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _delayms
	.dbline 164
; 
; 	LCD_control|=1<<LCD_RST;
	sbi 0x12,5
	.dbline 165
;     delayms(5);     // wait for the init routine to finish
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _delayms
	.dbline 168
; 
; //  SdCmd(0xae);    // Display off **hardware reset default**
;     SdCmd(0x48);    // Display Duty Ratio = 1/96
	ldi R16,72
	xcall _SdCmd
	.dbline 169
;     SdCmd(0x60);    // (two byte instruction)
	ldi R16,96
	xcall _SdCmd
	.dbline 170
;     SdCmd(0xa1);    // ADC = 1, reverse (flip x-direction)
	ldi R16,161
	xcall _SdCmd
	.dbline 171
;     SdCmd(0xc8);    // SHL = 1, reverse (flip y-direction)
	ldi R16,200
	xcall _SdCmd
	.dbline 172
;     SdCmd(0x44);    // COM0Reg = 16
	ldi R16,68
	xcall _SdCmd
	.dbline 173
;     SdCmd(0x10);    // (two byte instruction)
	ldi R16,16
	xcall _SdCmd
	.dbline 174
;     SdCmd(0x40);    // Display Start Line = 0
	ldi R16,64
	xcall _SdCmd
	.dbline 175
;     SdCmd(0x00);    // (two byte instruction)
	clr R16
	xcall _SdCmd
	.dbline 176
;     SdCmd(0xab);    // Osc on strat
	ldi R16,171
	xcall _SdCmd
	.dbline 177
;     SdCmd(0x66);    // DC-DC StepUp = 5x boosting
	ldi R16,102
	xcall _SdCmd
	.dbline 179
; 
;     SdCmd(0x27);    // 1+(Rb/Ra) = 7.2 (highest value)
	ldi R16,39
	xcall _SdCmd
	.dbline 180
;     SdCmd(0x81);    // ElecVol = 32 (middle value)
	ldi R16,129
	xcall _SdCmd
	.dbline 181
;     SdCmd(0x20);    // (two byte instruction)
	ldi R16,32
	xcall _SdCmd
	.dbline 182
;     SdCmd(0x54);    // LCD bias = 1/9 (adjusted for better control)
	ldi R16,84
	xcall _SdCmd
	.dbline 186
; //  SdCmd(0x4c);    // N-line inversion = frame inversion **hardware reset default**
; //  SdCmd(0x00);    // (two byte instruction) **hardware reset default**
; 
;     SdCmd(0x93);    // FRC=4 PWM=15
	ldi R16,147
	xcall _SdCmd
	.dbline 188
; 
;     SdCmd(0x88);    // white mode (two byte instruction)
	ldi R16,136
	xcall _SdCmd
	.dbline 189
;     SdCmd(0x00);    // 1st Frame Pulse width = 00h
	clr R16
	xcall _SdCmd
	.dbline 191
;                     // 2nd Frame Pulse width = 00h
;     SdCmd(0x89);    // white mode (two byte instruction)
	ldi R16,137
	xcall _SdCmd
	.dbline 192
;     SdCmd(0x00);    // 3rd Frame Pulse width = 00h
	clr R16
	xcall _SdCmd
	.dbline 195
;                     // 4th Frame Pulse width = 00h
; 
;     SdCmd(0x8a);    // light gray mode (two byte instruction)
	ldi R16,138
	xcall _SdCmd
	.dbline 196
;     SdCmd(0x00);    // 1st Frame Pulse width = 08h
	clr R16
	xcall _SdCmd
	.dbline 198
;                     // 2nd Frame Pulse width = 08h
;     SdCmd(0x8b);    // white mode (two byte instruction)
	ldi R16,139
	xcall _SdCmd
	.dbline 199
;     SdCmd(0x00);    // 3rd Frame Pulse width = 08h
	clr R16
	xcall _SdCmd
	.dbline 202
;                     // 4th Frame Pulse width = 08h
; 
;     SdCmd(0x8c);    // dark gray mode (two byte instruction)
	ldi R16,140
	xcall _SdCmd
	.dbline 203
;     SdCmd(0xff);    // 1st Frame Pulse width = 0Bh
	ldi R16,255
	xcall _SdCmd
	.dbline 205
;                     // 2nd Frame Pulse width = 0Bh
;     SdCmd(0x8d);    // white mode (two byte instruction)
	ldi R16,141
	xcall _SdCmd
	.dbline 206
;     SdCmd(0xff);    // 3rd Frame Pulse width = 0Bh
	ldi R16,255
	xcall _SdCmd
	.dbline 209
;                     // 4th Frame Pulse width = 0Bh
; 
;     SdCmd(0x8e);    // dark gray mode (two byte instruction)
	ldi R16,142
	xcall _SdCmd
	.dbline 210
;     SdCmd(0xff);    // 1st Frame Pulse width = 0Eh (set to reduce crosstalk)
	ldi R16,255
	xcall _SdCmd
	.dbline 212
;                     // 2nd Frame Pulse width = 0Eh (set to reduce crosstalk)
;     SdCmd(0x8f);    // white mode (two byte instruction)
	ldi R16,143
	xcall _SdCmd
	.dbline 213
;     SdCmd(0xff);    // 3rd Frame Pulse width = 0Eh (set to reduce crosstalk)
	ldi R16,255
	xcall _SdCmd
	.dbline 216
;                     // 4th Frame Pulse width = 0Eh (set to reduce crosstalk)
; 
;     SdCmd(0x2C);    // power ctl = DC-DC ON
	ldi R16,44
	xcall _SdCmd
	.dbline 217
;     delayms(1); 
	ldi R16,1
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _delayms
	.dbline 218
;     SdCmd(0x2f);    // power ctl = Voltage Regulator ON
	ldi R16,47
	xcall _SdCmd
	.dbline 219
;     delayms(1);
	ldi R16,1
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _delayms
	.dbline 220
;     SdCmd(0x2f);    // power ctl = Voltage follower ON
	ldi R16,47
	xcall _SdCmd
	.dbline 221
;     delayms(1);
	ldi R16,1
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _delayms
	.dbline 223
; 
;     SdCmd(0xaf);    // display ON
	ldi R16,175
	xcall _SdCmd
	.dbline -2
L36:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_init _LCD_init fV
;            ret -> <dead>
;        csdbuff -> y+0
	.even
_LCD_init::
	sbiw R28,16
	.dbline -1
	.dbline 227
;  }
; //------------------------------------------------------------------------------- 
; void LCD_init(void)                      					   //模块复位与初始化  
;  {   
	.dbline 229
;     UINT8 csdbuff[16],ret;
; 	SPCR = 0x50; 
	ldi R24,80
	out 0xd,R24
	.dbline 230
; 	DDRD|=1<<LCD_CS;
	sbi 0x11,6
	.dbline 231
; 	DDRD|=1<<LCD_RS;
	sbi 0x11,4
	.dbline 232
; 	DDRD|=1<<LCD_RST;
	sbi 0x11,5
	.dbline 234
; 	
;     LCD_init_initialize();	 								   //LCD初始化 
	xcall _LCD_init_initialize
	.dbline 235
; 	SdPage();    											   // 清屏
	xcall _SdPage
	.dbline 236
; 	SPCR = 0x54;
	ldi R24,84
	out 0xd,R24
	.dbline -2
L37:
	adiw R28,16
	.dbline 0 ; func end
	ret
	.dbsym l ret 1 c
	.dbsym l csdbuff 0 A[16:16]c
	.dbend

⌨️ 快捷键说明

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