??? 04/21/08 21:50 Modified: 04/21/08 21:51 Read: times |
#153788 - Hantronix LCD 4 bit mode |
a friend ran out of the LCDs he uses (discontinued) and he bought some Hantronix.
I just can't get them to initialize (the manual states how, but it does not work. http://www.hantronix.com/down/char-comm.pdf signal paths are verified. Erik here is the initializer (the original code is a mess, some may have permeated) ;///////////////////////////////////////////////////////////////////// ; initialize hantronix display in 4 bit mode haninit: push acc push RB06 mov r6,#200 ;"wait 15ms or more" HIinwt: lcall loop100us djnz r6,HIinwt anl p1,#001h ; clr dRS - clr dR_W - clr dENB command - write - ready to strobe orl p1,#00110000b ; Function Set 8 bit lcall hancmd ;3 mov r6,#50 ;"wait 4.1ms or more" HIwt01: lcall loop100us djnz r6,HIwt01 anl p1,#00fh orl p1,#00110000b ;function set 8 bit (2x) lcall hancmd ;3 mov r6,#5 ;"wait 100us or more" HIwt02: lcall loop100us djnz r6,HIwt02 anl p1,#00fh orl p1,#00110000b ;function set 8 bit (2x) lcall hancmd ;3 anl p1,#00fh orl p1,#00100000b ;function set 8 bit (2x) lcall hancmd ;2 anl p1,#00fh orl p1,#00100000b ;function set 8 bit (2x) lcall hancmd ;2 - anl p1,#00fh orl p1,#10000000b ;function set 8 bit (2x) lcall hancmd ;8 anl p1,#00fh orl p1,#00000000b ;function set 8 bit (2x) lcall hancmd ;0 - anl p1,#00fh orl p1,#10000000b ;function set 8 bit (2x) lcall hancmd ;8 anl p1,#00fh orl p1,#00000000b ;function set 8 bit (2x) lcall hancmd ;0 - anl p1,#00fh orl p1,#00010000b ;function set 8 bit (2x) lcall hancmd ;1 anl p1,#00fh orl p1,#00000000b ;function set 8 bit (2x) lcall hancmd ;0 anl p1,#00fh orl p1,#01000000b ;function set 8 bit (2x) lcall hancmd ;4 pop RB06 pop acc ret ;//////////////////////////////////////////////////////////////////// ; ; han2cmd feed full byte command to hantronix module ; han2dat feed full byte data to hantronix module ; ; data must be in acc (first nibble left) han2cmd: push acc anl a,#0f0h mov p1,a call hancmd pop acc push acc swap a anl a,#0f0h mov p1,a call hancmd pop acc ret han2dat: push acc anl a,#0f0h mov p1,a call handat pop acc push acc swap a anl a,#0f0h mov p1,a call handat pop acc ret ;//////////////////////////////////////////////////////////////////// ; ; hancmd feed command to hantronix module ; handat feed data to hantronix module ; ; data must be preloadedd into p1 hancmd: clr dRS ; RS low for a command byte. sjmp HDcomm handat: setb dRS ; RS high for a data byte. HDcomm: clr dR_W ; R/w low for a write mode nop nop nop setb dENB nop nop nop clr dENB ;enable pulse nop nop nop ; Check Busy orl p1,#0f0h ;configure data bits on port1 for input setb dR_W ;set RW to read clr dRS ;set RS to command HDbsylp: nop nop nop setb dENB ;generate enable pulse nop nop nop mov a,p1 clr dENB nop anl a,#80h ;check bit#7 busy flag jnz HDbsylp ;keep waiting until busy flag clears ; must check twice HDbsylp2: nop nop nop setb dENB ;generate enable pulse nop nop nop mov a,p1 clr dENB nop anl a,#80h ;check bit#7 busy flag jnz HDbsylp2 ;keep waiting until busy flag clears clr dR_W ;return to write mode ret |
Topic | Author | Date |
Hantronix LCD 4 bit mode | 01/01/70 00:00 | |
Busy bit checking | 01/01/70 00:00 | |
Nibble Mode... | 01/01/70 00:00 | |
appreciate all | 01/01/70 00:00 | |
your datasheet is compatable with HD44780 | 01/01/70 00:00 | |
No busy flag until the end of software init | 01/01/70 00:00 | |
the code 'runs'![]() | 01/01/70 00:00 |