Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 ORG 0H MOV A,#38H ; command ACALL COMNWRT ;call command ACALL DELAY ;give LCD some time MOV A,#0EH ;display on, cursor on ACALL COMNWRT ;call command MOV A,#01 ;clear LCD ACALL COMNWRT ;call command ACALL DELAY ;give LCD some time MOV A,#06H ;shift cursor right ACALL COMNWRT ;call command subroutine ACALL DELAY ;give LCD some time MOV A,#84H ACALL COMNWRT ;call command ACALL DELAY ;give LCD some time MOV A,#'V' ;display letter J ACALL DATAWRT ;call display ACALL DELAY ;give LCD some time MOV A,#'E' ;display letter J ACALL DATAWRT ;call display ACALL DELAY ;give LCD some time MOV A,#'A' ;display letter J ACALL DATAWRT ;call display ACALL DELAY ;give LCD some time MOV A,#'D' ;display letter D ACALL DATAWRT ;call display AGAIN: SJMP AGAIN ;stay here COMNWRT: ;send command to LCD MOV P1,A ;copy reg A to port 1 CLR P2.0 ;RS=0 for command CLR P2.1 ;R/W=0 for write SETB P2.2 ;E=1 for high pulse ACALL DELAY ;give LCD some time CLR P2.2 ;E=0 for H-to-L pulse RET DATAWRT: ;write data to LCD MOV P1,A ;copy reg A to port 1 SETB P2.0 ;RS=1 for data CLR P2.1 ;R/W=0 for write SETB P2.2 ;E=1 for high pulse ACALL DELAY ;give LCD some time CLR P2.2 RET DELAY: MOV R3,#50 HERE2: MOV R4,#255 HERE: DJNZ R4,HERE DJNZ R3,HERE2 RET END
Hello Genovator,Hi.
I couldn't spot any subroutine dedicated to scroll the displayed message. Would you tell me where you are sending command for scrolling?
Maybe you have to write command 18H after your message is displayed.
I want scroll message ''VEAD'' continuously on LCDhello
do you want to scroll letter by letter or pixel by pixel ?
if think 0x18h LCD Cde is for letter shift .. (not sure, to confirm by other ?)
for pixel by pixel you must use the Char Police definition (5x7 or 6x8) and use a LCD with grafic access
like a Nokia 5110 or other to be able to change only a pixel not a complete char at each time.
i did a moving message of 32 cars ,pixel by pixel ,on a POV(HAPR) clock.
in asm MPLAB 16F876..
you can have a look on it to understand How To do it.
- Define what is your maximum length of message to display
- at what speed ? any second ?
- what is the resolution of one char (5x7 or 6x8 or ?) ?
-so you can define a elementary pixel clock wich is the base of the application
the main difficulty is the frontiere (limite) between 2 caracteres .. on pixel belong to the previous char, the following pixel belong to the next char
it is a very good subject to learn about algorytm and software.
Ok, but you don't answer to the question :I want scroll message ''VEAD'' continuously on LCD
Ok, but you don't answer to the question :
is the scrolling step one char or one pixel of a char ?
Hello Genovator,
I wrote that command but my message ''vead" is not scrolling on lcd
I did what you saidCan you locate for me in your code where you written that command? I am not sure if pixel shift is available in a 16x2 LCD controller. Couldn't found it in datasheets though. But for char shift, try adding the following after line 26 in the code of post #1:
MOV A,#018H
ACALL COMNWRT
*Call for a delay and repeat the command.
Didn't tested, but it should work.
ORG 0H
MOV A,#38H ; command
ACALL COMNWRT ;call command
ACALL DELAY ;give LCD some time
MOV A,#0EH ;display on, cursor on
ACALL COMNWRT ;call command
MOV A,#01 ;clear LCD
ACALL COMNWRT ;call command
ACALL DELAY ;give LCD some time
MOV A,#06H ;shift cursor right
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#84H
ACALL COMNWRT ;call command
ACALL DELAY ;give LCD some time
MOV A,#'V' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'E' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'A' ;display letter J
ACALL DATAWRT ;call display
ACALL DELAY ;give LCD some time
MOV A,#'D' ;display letter D
ACALL DATAWRT ;call display
MOV A,#018H
ACALL COMNWRT
AGAIN: SJMP AGAIN ;stay here
COMNWRT: ;send command to LCD
MOV P1,A ;copy reg A to port 1
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2 ;E=0 for H-to-L pulse
RET
DATAWRT: ;write data to LCD
MOV P1,A ;copy reg A to port 1
SETB P2.0 ;RS=1 for data
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
ACALL DELAY ;give LCD some time
CLR P2.2
RET
DELAY: MOV R3,#50
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
ORG 0H
RS EQU P2.0
RW EQU P2.1
EN EQU P2.2
PDATA EQU P1
MAIN:
ACALL INIT ;INITIALIZE LCD
DISPLAY: ;DISPLAY 'VEAD VEAD VEAD'
MOV DPTR,#MESSAGE ;POINT DPTR TO BRGINNING OF MESSAGE
DLOOP: CLR A ;CLEAR ACC
MOVC A,@A+DPTR
JNZ DISP1
ACALL SCROLL
HERE: AJMP HERE ;STOP HERE
;------------------------------------------------------
DISP1: ACALL DATAWRT ;DISPLAY TEXT IN ACC
ACALL DELAY
INC DPTR
AJMP DLOOP
MESSAGE: DB 'VEAD VEAD VEAD ' ;TEXT TO PRINT ON LCD
DB 00 ;END OF TEXT
;-------------------------------------------------------
SCROLL:
MOV R5,#18
SLOOP: ACALL ROTATE_RIGHT
DJNZ R5,SLOOP
RET
ROTATE_LEFT: ;FOR SCROLLING LEFT TO RIGHT
CLR RS
MOV PDATA,#18h
SETB EN
CLR EN
ACALL DELAY
ACALL DELAY
ACALL DELAY
RET
ROTATE_RIGHT: ;FOR SCROLLING RIGHT TO LEFT
CLR RS
MOV PDATA,#1Eh
SETB EN
CLR EN
ACALL DELAY
ACALL DELAY
ACALL DELAY
RET
;----------------------------------------------
INIT: MOV A,#38H ; initialize LCD
ACALL COMNWRT
ACALL DELAY
MOV A,#0EH ;display on, cursor on
ACALL COMNWRT
MOV A,#01 ;clear LCD
ACALL COMNWRT
ACALL DELAY
MOV A,#06 ;shift cursor right
ACALL COMNWRT
ACALL DELAY
MOV A,#80H
ACALL COMNWRT
ACALL DELAY
RET
COMNWRT: ;send command to LCD
MOV PDATA,A ;copy reg A to port 1
CLR RS ;RS=0 for command
CLR RW ;R/W=0 for write
SETB EN ;E=1 for high pulse
ACALL DELAY
CLR EN ;E=0 for H-to-L pulse
RET
DATAWRT: ;write data to LCD
MOV PDATA,A ;copy reg A to port 1
SETB RS ;RS=1 for data
CLR RW ;R/W=0 for write
SETB EN ;E=1 for high pulse
ACALL DELAY
CLR EN
RET
;-----------delay subroutine--------------------
DELAY: MOV R3,#50
DEL2: MOV R4,#255
DEL: DJNZ R4,DEL
DJNZ R3,DEL2
RET
END
hello AllenTry the codes here...
Code:ORG 0H RS EQU P2.0 RW EQU P2.1 EN EQU P2.2 PDATA EQU P1 MAIN: ACALL INIT ;INITIALIZE LCD DISPLAY: ;DISPLAY 'VEAD VEAD VEAD' MOV DPTR,#MESSAGE ;POINT DPTR TO BRGINNING OF MESSAGE DLOOP: CLR A ;CLEAR ACC MOVC A,@A+DPTR JNZ DISP1 ACALL SCROLL HERE: AJMP HERE ;STOP HERE ;------------------------------------------------------ DISP1: ACALL DATAWRT ;DISPLAY TEXT IN ACC ACALL DELAY INC DPTR AJMP DLOOP MESSAGE: DB 'VEAD VEAD VEAD ' ;TEXT TO PRINT ON LCD DB 00 ;END OF TEXT ;------------------------------------------------------- SCROLL: MOV R5,#18 SLOOP: ACALL ROTATE_RIGHT DJNZ R5,SLOOP RET ROTATE_LEFT: ;FOR SCROLLING LEFT TO RIGHT CLR RS MOV PDATA,#18h SETB EN CLR EN ACALL DELAY ACALL DELAY ACALL DELAY RET ROTATE_RIGHT: ;FOR SCROLLING RIGHT TO LEFT CLR RS MOV PDATA,#1Eh SETB EN CLR EN ACALL DELAY ACALL DELAY ACALL DELAY RET ;---------------------------------------------- INIT: MOV A,#38H ; initialize LCD ACALL COMNWRT ACALL DELAY MOV A,#0EH ;display on, cursor on ACALL COMNWRT MOV A,#01 ;clear LCD ACALL COMNWRT ACALL DELAY MOV A,#06 ;shift cursor right ACALL COMNWRT ACALL DELAY MOV A,#80H ACALL COMNWRT ACALL DELAY RET COMNWRT: ;send command to LCD MOV PDATA,A ;copy reg A to port 1 CLR RS ;RS=0 for command CLR RW ;R/W=0 for write SETB EN ;E=1 for high pulse ACALL DELAY CLR EN ;E=0 for H-to-L pulse RET DATAWRT: ;write data to LCD MOV PDATA,A ;copy reg A to port 1 SETB RS ;RS=1 for data CLR RW ;R/W=0 for write SETB EN ;E=1 for high pulse ACALL DELAY CLR EN RET ;-----------delay subroutine-------------------- DELAY: MOV R3,#50 DEL2: MOV R4,#255 DEL: DJNZ R4,DEL DJNZ R3,DEL2 RET END
Allen
Do you want someone to make the complete code for you? Its your task and you have to do it. We members will try to identify the problem for you, and can give you suggestions. Now as you see neither @Allen's, nor my codes have any infinite loops to repeat the scrolling, you can add it by yourself. All you have to do is do some magic on "HERE: AJMP HERE" loop. ;-)hello Allen
thank you for help I tried your code but same problem. now message repeating in only one time. message should be repeat continuously
hello Allen
thank you for help I tried your code but same problem. now message repeating in only one time. message should be repeat continuously
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?