
;-----------------------------------------------------------------
; Name:			LCD Test.asm
; Description:	Tests the addition of an LCD to STK500
;				

; Author:		Max Koessick
; Class:		EEL5666C, Intelligent Machine Design Lab
; Date:			June 22, 2003
; Revision		1.a
; Changes to Date:
;				6/22/03 First Revision
;				7/7/03	Changed Initialization procedure to include file
;				

.nolist								; turn listing off
.include "m128def.inc"
.list

; Interrupt service vectors

.org $0000
	rjmp Reset						; Reset vector


;---------------------------------------------------------------------
; Reset vector
;---------------------------------------------------------------------
Reset:
;---------------------------------------------------------------------
; Register defines for main loop
;---------------------------------------------------------------------

.def		mpr		=r16			; defines multipurpose register

;-----Setting Stackpointer--------------------------------------------
	ldi		MPR,low(RAMEND)			; Set stackptr to ram end
	out		SPL,MPR
	ldi 	MPR, high(RAMEND)
	out 	SPH, MPR

;-----Set Port Directions---------------------------------------------
	ser		mpr						; Set mpr to $FF to...
	out		DDRB,mpr				; ...set data direction to "out"
									; = DataBus DB[7..0]
;	ser		mpr
	out 	DDRE,mpr				; Set 'E' as output
									; control Bits

;Write Characters to Screen-------------------------------------------

	call	LCDInit
	
	ldi		mpr,0b10000000			; Activate Data Register
	out		PORTE,mpr



	ldi		ZH,high(varlist*2)		; Initialize Z Pointer for LPM command
	ldi		ZL,low(varlist*2)

NextChar:
	lpm		mpr,Z+					; Get first/next character

	cpi		mpr,$ff					; Is this the string terminator?
									; Yes, then get next; no, then end
	breq	mainloop

	out		PORTB,mpr

	ldi		mpr,0b11000000			; Activate LCD Enable
	out		PORTE,mpr

	ldi		mpr,0b10000000
	out		PORTE,mpr				; Deactivate LCD Enable

	call	delay40us

	rjmp	NextChar				; Repeat Loop until string Terminator

mainloop:

	rjmp 	mainloop

varlist:
.dw $6152,$676e,$3A65,$00FF 		; "Range:" in ASCII (Hex)


.nolist								; turn listing off
.include "LCD_Init.inc"
.list

; End of File*********************************************************