At 04:24 PM 11/24/99 +0700, Harry wrote: >Hi Robert, >I have tried this code. Use 16x2 character LCD, 4 bit mode, use RA3-0 to LCD. >It is success. > >Note : Be carefull for the delay. It uses maximum delay, because it does not >read the flag (read mode). > >;/////////////////////////////////////////////////////////// >;*********************************************************** >; LCD Initialization >;*********************************************************** >LCD_initialization > call Dlay5 ; Wait 20 msecs before Reset > call Dlay5 > call Dlay5 > call Dlay5 >;----------------------- once 4 bit --------------------- > bcf STATUS,C > movlw 0x03 ; Reset Command (data was in 'W') > call NybbleOut ; Send the Nybble > call Dlay5 ; Wait 5 msecs before Sending Again > > bcf STATUS,C > movlw 0x03 > call NybbleOut ; Send the Nybble > call Dlay160 ; Wait 160 usecs before > Sending the >Third Time > > bcf STATUS,C > movlw 0x03 > call NybbleOut ; Send the Nybble > call Dlay160 ; Wait 160 usecs before > Sending the >Third Time > > bcf STATUS, C > movlw 0x02 ; Set 4 Bit Mode > call NybbleOut > call Dlay160 > >;----------------------- twice 4 bits -------------------- > movlw 0x028 ; Note that it is a 2 Line Display > call SendINS Thanks, Harry, and also Andrew! However, my question was why this 'Wizard of Oz' 3-times clicking of 8-bit interface is necessary. Since my post, I have finally found reference to this in the Hitachi 44780 documentation. 1. Under normal conditions on power-up (> 4.5 V within 15 ms), the controller arises in 8-bit interface mode and is ready for action. A single 0x2 will put it in 4-bit interface mode, and then the, e.g., 0x'2' and 0x'8' nybbles will put it into the actual interface mode. 2. Under poor voltage rise conditions (> 2.7 V within 40 ms), the controller will arise in an unknown state. In this case, Hitachi suggests: 2.1. Wait 40 ms. 2.2. Send 0x'3'. 2.3. Wait > 4.1 ms. 2.4. Send 0x'3'. 2.5. Wait > 100 us. 2.6. Send 0x'3'. 2.7. Wait > 40 us. 2.8. Send 0x'2'. (Start of normal operations.) 2.9. Send 0x'2' and, e.g., 0x'8'. It's now clear to me what the contradictions are. If the power-up can be presumed to be reliable, then you can go direct into 4-bit mode with no 8-bit shenanigans. However, the first 0x'2' you send must be followed by a > 4.1 ms delay, since the controller is slow on its first instruction received. If the power-up is poor, you must send the three 8-bit 'wake-up' instructions, as specified. So the routines often quoted (e.g., Mike Predko's) can probably be considered examples of worst-case design. The problem is that in the event of poor power-up, the correct initial delay is not 15 ms or even 20 ms, but rather 40 ms by the Hitachi documentation. Based on all of this, I believe the 2.1-2.9 sequence above is the correct start-up procedure for worst-case. ================================================================ Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: ral@lcfltd.com Least Cost Formulations, Ltd. URL: http://lcfltd.com/ 824 Timberlake Drive Tel: 757-467-0954 Virginia Beach, VA 23464-3239 Fax: 757-467-2947 "Vere scire est per causae scire" ================================================================