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

📄 lcd.s

📁 ICCAVR Rainguage counter program
💻 S
字号:
	.module lcd.c
	.area text(rom, con, rel)
	.dbfile C:\RGauge\lcd.c
	.dbfunc e LCD_Delay _LCD_Delay fV
;              n -> y+0
;              d -> y+8
	.even
_LCD_Delay::
	xcall push_arg4
	xcall push_gset2
	sbiw R28,4
	.dbline -1
	.dbline 5
; //LCD DISPLAY
; #include "lcd.h"
; 
; void LCD_Delay (unsigned long int d) 
; { 
	.dbline 7
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	std z+0,R20
	std z+1,R21
	std z+2,R22
	std z+3,R23
	xjmp L5
L2:
	.dbline 7
L3:
	.dbline 7
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	movw R30,R28
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
L5:
	.dbline 7
;     unsigned long int n; 
;     for (n = 0; n < d; n++); 
	movw R30,R28
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	movw R30,R28
	ldd R6,z+0
	ldd R7,z+1
	ldd R8,z+2
	ldd R9,z+3
	cp R6,R2
	cpc R7,R3
	cpc R8,R4
	cpc R9,R5
	brlo L2
	.dbline -2
L1:
	adiw R28,4
	xcall pop_gset2
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l n 0 l
	.dbsym l d 8 l
	.dbend
	.dbfunc e LCD_IO_INIT _LCD_IO_INIT fV
	.even
_LCD_IO_INIT::
	xcall push_gset2
	.dbline -1
	.dbline 11
; } 
; 
; void LCD_IO_INIT (void) 
; { 
	.dbline 12
;     DataDDR = 0xFF; // Selected PORT is the LCD DATA LINES 
	ldi R24,255
	out 0x1a,R24
	.dbline 13
;     DataPort = 0x00; 
	clr R2
	out 0x1b,R2
	.dbline 14
;     CtrlDDR |= 0x07; // the LCD CONTROL LINES 
	in R24,0x14
	ori R24,7
	out 0x14,R24
	.dbline 15
;     CtrlPort |= 0x05; // LCD_RS = HIGH, LCD_RW = LOW, LCD_E = HIGH,
	in R24,0x15
	ori R24,5
	out 0x15,R24
	.dbline 16
;     LCD_Delay (500); // Wait for the up LCD to power up          
	ldi R16,244
	ldi R17,1
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline -2
L6:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_INIT _LCD_INIT fV
	.even
_LCD_INIT::
	xcall push_gset2
	.dbline -1
	.dbline 20
; } 
; 
; void LCD_INIT (void) 
; { 
	.dbline 21
;     LCD_PutCmd (PWR_CMD); // Power up the display 
	ldi R16,12
	xcall _LCD_PutCmd
	.dbline 22
;     LCD_PutCmd (DL_CMD);  // Set to 4 lines, 8 bit, no cursor 
	ldi R16,56
	xcall _LCD_PutCmd
	.dbline 23
;     LCD_PutCmd (CLR_DSP); // Clear the display 
	ldi R16,1
	xcall _LCD_PutCmd
	.dbline 24
;     LCD_Delay (500); // Wait for the LCD to boot up
	ldi R16,244
	ldi R17,1
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline 26
; 	
; 	LCD_PutCmd(LINE1);
	ldi R16,128
	xcall _LCD_PutCmd
	.dbline 27
; 	LCD_PutString("System Starting"); //init message displayed on line 1
	ldi R16,<L8
	ldi R17,>L8
	xcall _LCD_PutString
	.dbline -2
L7:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e LCD_PutCmd _LCD_PutCmd fV
;              c -> R10
	.even
_LCD_PutCmd::
	xcall push_gset3
	mov R10,R16
	.dbline -1
	.dbline 32
; 
; } 
;   
; void LCD_PutCmd (char c) 
; { 
	.dbline 33
;   CtrlPort &= ~(1<<LCD_RS); 
	cbi 0x15,0
	.dbline 34
;   LCD_Delay (5); // Wait for the proper setup time to respond to the RS control line  
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline 35
;   LCD_PutChar(c); 
	mov R16,R10
	xcall _LCD_PutChar
	.dbline 36
;   LCD_Delay (5); // Wait for the proper setup time to respond to the command being applied 
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline 37
;   CtrlPort |= (1<<LCD_RS); 
	sbi 0x15,0
	.dbline -2
L9:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r c 10 c
	.dbend
	.dbfunc e LCD_PutChar _LCD_PutChar fV
;              c -> R10
	.even
_LCD_PutChar::
	xcall push_gset3
	mov R10,R16
	.dbline -1
	.dbline 41
; } 
; 
; void LCD_PutChar (char c) 
; { 
	.dbline 42
;     CtrlPort |= (1<<LCD_E); 
	sbi 0x15,2
	.dbline 43
;     LCD_Delay (5); // Wait for the proper setup time to respond to the E pulse    
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline 44
;     DataPort = c; 
	out 0x1b,R10
	.dbline 45
;     LCD_Delay (5); // Wait for the proper setup time to respond to the character being applied 
	ldi R16,5
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xcall _LCD_Delay
	.dbline 46
;     CtrlPort &= ~(1<<LCD_E); 
	cbi 0x15,2
	.dbline -2
L10:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r c 10 c
	.dbend
	.dbfunc e LCD_PutString _LCD_PutString fV
;              p -> R20,R21
	.even
_LCD_PutString::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 50
; } 
;   
; void LCD_PutString (unsigned char *p) 
; { 
	xjmp L13
L12:
	.dbline 53
	.dbline 54
	movw R30,R20
	ldd R16,z+0
	xcall _LCD_PutChar
	.dbline 55
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 56
L13:
	.dbline 53
; 
;     // Keep sending data until the p pointer is end. 
;         while(*p) {
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L12
	.dbline -2
L11:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r p 20 pc
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\RGauge\lcd.c
L8:
	.blkb 16
	.area idata
	.byte 'S,'y,'s,'t,'e,'m,32,'S,'t,'a,'r,'t,'i,'n,'g,0
	.area data(ram, con, rel)
	.dbfile C:\RGauge\lcd.c

⌨️ 快捷键说明

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