LCD Edsim

Embed Size (px)

DESCRIPTION

edsim

Citation preview

RS equ P2.3EN equ P2.2; put data in RAMMOV 30H, #'H'MOV 31H, #'E'MOV 32H, #'L'MOV 33H, #'L'; end of data marker MOV 34H, #'L'; end of data marker MOV 35H, #'O'; end of data markerMOV 36H, #0; end of data marker; initialise the display; see instruction set for detailsCLR RS ;RS=0 to select Control Reg.

mov a, #20h ; 28 = function set 4bit 5x7 dotsmov P1,aSETB EN; |CLR EN; | negative edge on ECALL delay; wait for BF to clearSETB EN CLR EN; | negative edge

mov a, #80hmov P1,aSETB EN; |CLR EN; | negative edge on E; function set low nibble sentCALL delay; wait for BF to clear

mov a, #00h ; 06 = Entry modemov P1,aSETB EN; |CLR EN; | negative edge on E

mov a, #60hmov P1,a

SETB EN; |CLR EN; | negative edge on ECALL delay; wait for BF to clear

; display on/off control; the display is turned on, the cursor is turned on and blinking is turned onmov a, #00h ;0f= display on cursor blinkingmov P1,aSETB EN; |CLR EN; | negative edge on E

mov a, #0f0hmov P1,aSETB EN; |CLR EN; | negative edge on ECALL delay; wait for BF to clear

; send dataSETB RS;RS=1 to select data regMOV R1, #30H; loop:MOV A, @R1; move data pointed to by R1 to AJZ finish; if A is 0, then end of data has beenCALL sendCharacter; send data in A to LCD moduleINC R1; point to next piece of dataJMP loop; repeat

finish:JMP $

sendCharacter:mov p1,aSETB EN; |CLR EN; | negative edge on ESWAP Amov p1,aSETB EN; |CLR EN; | negative edge on ECALL delay; wait for BF to clear

delay:MOV R0, #50DJNZ R0, $RET