??? 04/04/05 15:01 Read: times |
#90970 - Code with comments Responding to: ???'s previous message |
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 ;Set port 0 as output MOV P2,#00 ;set port 2 as output LCALL INI_LCD ; Initialize LCD LCALL CLEAR_LCD ; Clear LCD LJMP START ; Go to start INI_LCD:SETB EN ;Start LCD command CLR RS ;It's a command CLR RW ;Write command MOV P0,#38H ;8x2 display CLR EN ;finish the command LCALL WAIT_LCD;Wait till bit 7 is low SETB EN ;Start LCD command CLR RS ;It's a command CLR RW ;Write command MOV P0,#0CH ;Turn LCD on, no cursor CLR EN ;finish the command LCALL WAIT_LCD ;Wait till bit 7 is low SETB EN ;Start LCD command CLR RS ;It's a command CLR RW ;Write command MOV P0,#06H ;Moves curso to right after char CLR EN ;finish the command LCALL WAIT_LCD ;Wait till bit 7 is low RET ;Return to caller 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,LCD still busy CLR EN ;finish the command CLR WR ;turn off RW for future commands RET ;Return to caller WRITE_TEXT:SETB EN ;start LCD command SETB RS ;Text is being sent CLR RW ;Write command MOV P0,A ;Move char to P0 CLR EN ;Finish command LCALL WAIT_LCD ;Wait till bit 7 is low POP DPH ;Restore Values POP DPL ;Restore Values LJMP DSPL_STR ; Go to address POSITION:SETB EN ;start LCD command CLR RS ;It's a command CLR RW ;Write command MOV P0,#0C0H ;Position on second line CLR EN ;finish the command LCALL WAIT_LCD ;Wait till bit 7 is low RET ;Return to caller CLEAR_LCD:SETB EN ;start LCD command CLR RS ;It's a command CLR RW ;Write command MOV P0,#01H ;Clear LCD CLR EN ;finish the command LCALL WAIT_LCD ;Wait till bit 7 is low RET Return to caller DSPL_STR: CLR A ;Clear Acc MOVC A,@A+DPTR ;Acc = charecter on string INC DPTR ;Increment DPTR PUSH DPL ;Protect values PUSH DPH ;Protect values CJNE A,#0FFH,WRITE_TEXT ;Jump if A is not 0FFH POP DPH ;Restore Values POP DPL ;Restore Values RET ;Return to caller SAY1: DB 'Welcome to FL107',0FFH ; First string SAY2: DB 'We love U!!!',0FFH ;Second String SAY3: DB 'Very much!!!',0FFH ;Third string SAY4: DB 'What do U think!',0FFH ;Fourth String DELAY:MOV R1,#08H ;Load value to R1 LOOP_3:MOV R2,#0FFH ;Load value to R2 LOOP_2:MOV R3,#0FFH ;Load value to R3 LOOP_1:DJNZ R3,LOOP_1; Decrement until zero DJNZ R2,LOOP_2 ;Decrement until zero DJNZ R1,LOOP_3 ;Decrement until zero RET ;Return to caller START: ;LCALL DELAY ;Wait 1 second MOV DPTR,#SAY1 ;Load String to DPTR LCALL DSPL_STR ;Display string on LCD LCALL DELAY ;Wait 1 second LCALL DELAY ;Wait 1 second MOV DPTR,#SAY2 ;Load String to DPTR LCALL CLEAR_LCD ;Clear LCD LCALL DSPL_STR ;Display string on LCD LCALL DELAY ;Wait 1 second LCALL DELAY ;Wait 1 second LCALL POSITION ;Position to start writing on 2nd line MOV DPTR,#SAY3 ;Load String to DPTR LCALL DSPL_STR ;Display string on LCD LCALL DELAY ;Wait 1 second LCALL DELAY ;Wait 1 second LCALL CLEAR_LCD ;Clear LCD MOV DPTR,#SAY4 ;Load String to DPTR LCALL DSPL_STR ;Display string on LCD LCALL DELAY ;Wait 1 second LCALL DELAY ;Wait 1 second LCALL CLEAR_LCD ;Clear LCD LJMP START ;Go to 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 |