2006/6/28, Stewart Abel : > I am trying to interface with a LCD which uses the HD44780 interface. I > am > using a PIC16f73. I am trying to use the LCD in 4bit mode connected to > PORTC. I am currently just getting a blank screen. I have put my code > below. Can anybody see where I have gone wrong or suggest anything I can > try please? 1) Obviously the code needs work. I recommend running it through a simulator step by step, and see the things that are going wrong (you can use breakpoints to jump over your delays). Others in the list have already commented on things. I wouldn't be concerned about read/modify/write at this time. Try to add comments to the code. 2) Is your contrast circuit working? Can you make the display go from blank to black by adjusting your contrast? If not, then this is also something that would need attention. 3) A known good implementation of 4-bit LCD can be found at http://www.myke.com/lcd.htm . The code uses a two-bit interface, and isn't that good either, but at least it is an implementation that works, from which you can create your own. I wouldn't be surprised if there weren't several implementations on piclist.com either. 4) I used the sequence 3332280801060C to initialise, which has worked with every LCD I encountered (of course, the "28" might need to change to 20, 38 or 30 depending on the size of the display). 5) Timing wise you seem to be on the careful side (which is no problem, the LCD is patient). The longest delay you need is 15ms after power up. From then on most data can be sent at 160us delays (there are some commands that take 5ms but those are rare). Also note that at 4 MHz there is no delay needed between the nybbles that form a byte sent to the LCD. Just put nybble on your port, blink enable, put the next nybble on the port, and blink enable, then wait 160us. Of course, 160us is the maximum, you can check the busy flag to see if you can send stuff sooner. Greetings, Maarten Hofman. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist