| ??? 10/19/01 01:15 Read: times |
#15848 - RE: Converting my o/p to drive LCD disp |
Thankyou for replying again.
Here is what I have done so far... ' Used Microcontroller: INCLUDE 89C4051.mc ' Used Portpins: Button1 EQU P3.0 Button2 EQU P3.1 EN EQU P3.2 'ENABLE RS EQU P3.3 'REG SELECT RW EQU P3.4 'READ/WRITE SELECT 'DB7 EQU P1.7 DATA EQU P1 ' Used RAM Bits Direction BIT 0h STOP BIT 0h Start: MOV DATA,#FFh 'Init: Set all pins from port 1 to high MOV PORT3,#00h 'Init: Set all pins from port 3 to high 'Initialise the LCD CLR RS CLR RW LCALL short_wait SETB EN LCALL short_wait MOV DATA,#30h NOP NOP CLR EN LCALL short_wait LCALL short_wait CLR RS CLR RW LCALL short_wait SETB EN LCALL short_wait MOV DATA,#30h NOP NOP CLR EN LCALL short_wait LCALL short_wait CLR RS CLR RW LCALL short_wait SETB EN LCALL short_wait MOV DATA,#30h NOP NOP CLR EN LCALL short_wait LCALL short_wait CLR RS CLR RW LCALL short_wait SETB EN LCALL short_wait MOV DATA,#38h NOP NOP CLR EN LCALL WAIT_LCD CLR RS CLR RW SETB EN LCALL short_wait MOV DATA,#0Eh NOP NOP CLR EN LCALL WAIT_LCD CLR RS CLR RW SETB EN LCALL short_wait MOV DATA,#06h NOP NOP CLR EN LCALL WAIT_LCD LCALL CLEAR_LCD MOV A,#FEh 'Set accu to FE(hex) = 254(dec) = 11111110(bin) Running_Light: JB Direction,Check_1 'Jump to "Check_1", if bit "Direction" is set INC A ' Else Inc Acc Check_1: JNB Direction,Check_2 'Jump to "Check_2", if bit "Direction" isn“t set DEC A 'Else Dec Acc Check_2: LCALL Wait 'Jump to wait LJMP Running_Light Wait: MOV R0,#7Fh 'Set register R0 to 7F(hex) = 255(dec) Wait_2: JNB Button1,Wait_3 'Jump to "Wait_3", if button 1 not pressed SETB Direction 'Set the bit "Direction" LCALL search_table 'Search & O/P Data Wait_3: JNB Button2,Wait_4 'Jump to "Wait_4", if button 2 not pressed CLR Direction 'Clear the bit "Direction" LCALL search_table 'Search & O/P Data Wait_4: MOV R1,#7Fh 'Set register R1 to FF(hex) = 255(dec) Wait_5: DJNZ R1,Wait_5 'R1 = R1-1: Jump to "Wait_5", if R1 > 0 MOV R3,#FFh 'Set Register R3 to #FFh MOV R4,#09h 'Set Register R4 to #09h LCALL Wait_6 DJNZ R0,Wait_2 'R1 = R1-1: Jump back to "wait_2", if R0 > 0 RET 'Jump back to "Running Lights" Wait_6: DJNZ R3,Wait_6 'Long Wait Loop DJNZ R4,Wait_6 'Long Wait Loop RET CLEAR_LCD: 'Clear the display CLR RS SETB EN LCALL short_wait MOV DATA,#01h LCALL short_wait LCALL short_wait CLR EN LCALL WAIT_LCD RET WAIT_LCD: 'Wait for LCD to become free CLR RS SETB RW LCALL short_wait SETB EN LCALL short_wait WAIT_LCD2: MOV DATA,#FFh MOV B,DATA JB B.7,WAIT_LCD2 'Wait for bit 7 tu drop CLR EN 'Finish the command CLR RW RET WRITE_TEXT: SETB RS CLR RW LCALL short_wait SETB EN LCALL short_wait MOV DATA,A LCALL short_wait CLR EN NOP LCALL WAIT_LCD RET search_table: 'PUSH ACC MOV R7,A MOV DPTR,#0000h MOV DPTR,#table 'point DPTR @ table loop: MOVC A,@A+DPTR 'get a character JZ exit 'jump if acc 0 to exit LCALL WRITE_TEXT 'write it to the port INC DPTR 'get next char CLR A 'clear acc for next character SJMP loop 'loop back to get a character 'exit of acc = 00 exit: 'POP ACC 'pop back the value of the acc MOV A,R7 RET short_wait: MOV R5,#FFh MOV R6,#0Fh short_wait2: DJNZ R5,short_wait2 short_wait3: DJNZ R6,short_wait3 RET table: DB "TX1240.0",Stop 'Just an experiment seems to work DB "TX1240.5",0h DB "TX1241.0",0h DB "TX1241.5",0h DB "TX1242.0",0h DB "TX1242.5",0h DB "TX1243.0",0h This goes on for DB "TX1367,5" |



