??? 03/27/12 17:40 Read: times |
#186911 - Tutorial/Book question about 8052/LCD |
EN equ P3.3 RW equ P3.4 RS equ P3.5 DAT equ P1 wait_lcd: clr RS ;command setb RW ;read command setb EN ;start lcd command mov P1, #0FFh mov A, P1 jb ACC.7, wait_lcd ;if bit 7 high, lcd still busy clr EN ;finish command clr RW ;turf off RW for future commands ret lcd_command: clr RS ;low to indicate command clr RW ;low to indicate write mov DAT, A setb EN ;high to initiate command mov R0, #30h loop: ;loops 48 times instead of 4 nop ; to compensate for the Dallas' speed djnz R0, loop clr EN lcall wait_lcd ;wait for command to execute ret init_lcd: mov A, #38h ;8-bit data bus, 5x8 font lcall lcd_command mov A, #0Eh ;turn on lcd, turn on cursor lcall lcd_command mov A, #06h ;turn on cursor auto advance lcall lcd_command ret clear_lcd: mov A, #01h lcall lcd_command ret write_lcd_text: setb RS ;RS high to indicate text clr RW ;RW low to indiacte write mov DAT, A setb EN ;high to initiate command mov R0, #30h loop2: ;loops 48 times instead of 4 nop ; to compensate for the Dallas' speed djnz R0, loop2 clr EN lcall wait_lcd ;wait for command to execute ret lcall init_lcd ;initialize lcd lcall clear_lcd ;clear screen mov A, #'H' ;send text data to lcd lcall write_lcd_text mov A, #'e' lcall write_lcd_text mov A, #'l' lcall write_lcd_text mov A, #'l' lcall write_lcd_text mov A, #'o' lcall write_lcd_text end Hook up is per the above schematic. Code is from Craig's book and tutorials on this site. All I get are first line dark squares and blank screen after adjusting contrast. No text. Anyone see the problem? |
Topic | Author | Date |
Tutorial/Book question about 8052/LCD | 01/01/70 00:00 | |
reset? | 01/01/70 00:00 | |
Problem solved | 01/01/70 00:00 | |
did you | 01/01/70 00:00 |