??? 04/04/05 13:42 Read: times |
#90958 - Can not write second line on LCD |
I am trying to write to a 8 by 2 lines LCD. When using the Tutorial in the website it works fine, I can write on Both lines but when I use the code below it writes on the first line but not on the second line. Please help. Please note that I use the ubrouting POSITION to write on the second line.
ORG 0000H DB0 EQU P0.0 DB1 EQU P0.1 DB2 EQU P0.2 DB3 EQU P0.3 DB4 EQU P0.4 DB5 EQU P0.5 DB6 EQU P0.6 DB7 EQU P0.7 EN EQU P2.7 RW EQU P2.6 RS EQU P2.5 MOV P0,#00 MOV P2,#00 LCALL INI_LCD LCALL CLEAR_LCD LJMP START INI_LCD:SETB EN CLR RS CLR RW MOV P0,#38H CLR EN LCALL WAIT_LCD SETB EN CLR RS CLR RW MOV P0,#0CH CLR EN LCALL WAIT_LCD SETB EN CLR RS CLR RW MOV P0,#06H CLR EN LCALL WAIT_LCD RET WAIT_LCD:SETB EN ;start LCD command CLR RS ;It's a command SETB RW ;It's a read command MOV P0,#0FFH ;set all pins high MOV A,P0 ;read the return value JB ACC.7,WAIT_LCD ;if bit 7 is high CLR EN ;finish the command CLR WR ;turn off RW for future commands RET WRITE_TEXT:SETB EN SETB RS CLR RW MOV P0,A CLR EN LCALL WAIT_LCD POP DPH POP DPL LJMP DSPL_STR POSITION:SETB EN CLR RS CLR RW MOV P0,#0C0H CLR EN LCALL WAIT_LCD RET CLEAR_LCD:SETB EN CLR RS CLR RW MOV P0,#01H CLR EN LCALL WAIT_LCD RET DSPL_STR: CLR A MOVC A,@A+DPTR INC DPTR PUSH DPL PUSH DPH CJNE A,#0FFH,WRITE_TEXT POP DPH POP DPL RET SAY1: DB 'Welcome to FL107',0FFH SAY2: DB 'We love U!!!',0FFH SAY3: DB 'Very much!!!',0FFH SAY4: DB 'What do U think!',0FFH DELAY:MOV R1,#08H LOOP_3:MOV R2,#0FFH LOOP_2:MOV R3,#0FFH LOOP_1:DJNZ R3,LOOP_1 DJNZ R2,LOOP_2 DJNZ R1,LOOP_3 RET START: ;LCALL DELAY MOV DPTR,#SAY1 LCALL DSPL_STR LCALL DELAY LCALL DELAY MOV DPTR,#SAY2 ;LCALL POSITION LCALL CLEAR_LCD LCALL DSPL_STR LCALL DELAY LCALL DELAY LCALL POSITION MOV DPTR,#SAY3 LCALL DSPL_STR LCALL DELAY LCALL DELAY LCALL CLEAR_LCD MOV DPTR,#SAY4 LCALL DSPL_STR LCALL DELAY LCALL DELAY LCALL CLEAR_LCD LJMP START END |
Topic | Author | Date |
Can not write second line on LCD | 01/01/70 00:00 | |
Since you do not believe in comments | 01/01/70 00:00 | |
Comments | 01/01/70 00:00 | |
what would you rather | 01/01/70 00:00 | |
Untidy | 01/01/70 00:00 | |
Code with comments | 01/01/70 00:00 | |
what happened | 01/01/70 00:00 | |
Did you check the second line address? | 01/01/70 00:00 | |
How to post code - detailed instructions | 01/01/70 00:00 | |
neatly formatted, yes but | 01/01/70 00:00 | |
0xC0 is correct | 01/01/70 00:00 | |
Can write anywhere | 01/01/70 00:00 | |
cal which calls which calls which calls | 01/01/70 00:00 | |
Works here | 01/01/70 00:00 | |
timing, maybe... | 01/01/70 00:00 | |
Timing?![]() | 01/01/70 00:00 | |
I am sure! | 01/01/70 00:00 | |
I am not sure now! | 01/01/70 00:00 |