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

📄 lcd.asm

📁 用ATMEGA8开发的MMC程式,可用AVR-GCC开发
💻 ASM
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;		LCD-Routinen			;;
;;		============			;;
;;		(c)andreas-s@web.de		;;
;;	4bit-Interface				;;
;;	DB4-DB7:	PC0-PC3			;;
;;	RS:		PC4			;;
;;	E:		PC5			;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	
.ORG	1160
	
	;sendet ein Datenbyte an das LCD
lcd_data:
	mov	work,	temp			;"Sicherungskopie" f黵
						;die 躡ertragung des 2.Nibbles
	swap	temp,				;Vertauschen
	andi	temp,	0b00001111		;oberes	Nibble auf Null	setzen
	sbr	temp,	1<<4			;entspricht 0b00010000
	out	LCD,	temp			;ausgeben
	rcall	lcd_enable			;Enable-Routine	aufrufen
						;2. Nibble kein swap da	es schon
						;an der	richtigen stelle ist
	andi	work,	0b00001111		;obere H鋖fte auf Null setzen	
	sbr	work,	1<<4			;entspricht 0b00010000
	out	LCD,	work			;ausgeben
	rcall	lcd_enable			;Enable-Routine	aufrufen
	rcall	delay50us			;Delay-Routine aufrufen
	ret					;zur點k	zum Hauptprogramm

	;sendet einen Befehl an	das LCD
lcd_command:					;wie lcd_data nur ohne RS zu setzen
	mov	work,	temp
	swap	temp
	andi	temp,	0b00001111
	out	LCD,	temp
	rcall	lcd_enable
	andi	work,	0b00001111
	out	LCD,	work
	rcall	lcd_enable
	rcall	delay50us
	ret

	;erzeugt den Enable-Puls
lcd_enable:
	sbi	LCD,	5			;Enable	high
	nop					;3 Taktzyklen	warten
	nop
	nop
	cbi	LCD,	5			;Enable	wieder low
	ret					;Und wieder zur點k											

	;Pause nach jeder 躡ertragung
delay50us:					;50us Pause
	ldi	temp,	$42
delay50us_:dec	temp
	brne	delay50us_
	ret					;wieder	zur點k

	;L鋘gere Pause f黵 manche Befehle
delay5ms:					;5ms Pause
	ldi	temp,	$21
WGLOOP0:ldi	work,	$C9
WGLOOP1:dec	work
	brne	WGLOOP1
	dec	temp
	brne	WGLOOP0
	ret					;wieder	zur點k

	;Initialisierung: muss ganz am Anfang des Programms aufgerufen werden
lcd_init:
	ldi	cnt,	10
powerupwait:
	rcall	delay5ms
	dec	cnt
	brne	powerupwait
	ldi	temp,	0b00000011		;muss 3mal hintereinander gesendet
	out	LCD,	temp			;werden	zur Initialisierung
	rcall	lcd_enable			;1
	rcall	delay5ms
	rcall	lcd_enable			;2
	rcall	delay5ms
	rcall	lcd_enable			;und 3!
	rcall	delay5ms
	ldi	temp,	0b00000010		;4bit-Modus einstellen
	out	LCD,	temp
	rcall	lcd_enable
	rcall	delay5ms
	ldi	temp,	0b00101000		;noch was einstellen...
	rcall	lcd_command
	ldi	temp,	0b00001100		;...nochwas...
	rcall	lcd_command
	ldi	temp,	0b00000100		;endlich fertig
	rcall	lcd_command
	ret

	;Sendet den Befehl zur L鰏chung des Displays
lcd_clear:
	ldi	temp,	0b00000001		;Display l鰏chen
	rcall	lcd_command
	rcall	delay5ms
	ret

⌨️ 快捷键说明

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