Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HD44780 LCD operation

Status
Not open for further replies.

ssylee

New Member
I'm having problems with my LCD (both in real life and simulator) on a
PIC18F system not showing anything, after ensuring that the hardware
is connected properly. I'm beginning to suspect that either my
sequence of operations on the LCD during the initialization before
writing anything isn't done properly, or the timing of the command
functions that I have called (those functions are built-in with mikroC
development suite) aren't proper for my LCD (even though their library
functions are said to be for HD44780 compatible LCDs). It would
fantastic if someone replies on the basic sequence of operations that
I should be instructing the LCD in order for it to work. I have
basically initialized in the program where the data port, RS, Enable,
and R/W pins are connected, turn on the LCD module, clear the display,
turn the cursor display/blinking off, and return the cursor to top
left corner. Thanks!
 
The mikroC libararies work fine... I've tested them. Check your connections, your contrast, and make sure you have Digital IO for the PIC pins feeding the LCD. If you want to look at some mikroC LCD source code, I wrote a program that writes the modules and functions based on your pin assignments. It helps optimize the code and speeds up the processes:

**broken link removed**
 
Last edited:
I have my ADCON1 register to be 0x0e or I believe to be using AN0 only. Also, TRISx = 0x01 would make all the bits 1-7 output and bit 0 input.
 
Deleted by my me as the OP has given his version of c code at the site mentioned.
 
Last edited:
ssylee said:
What's deleted by my me?
i did't see your post completely and the message was posted by me. Hence i have reoved the content that i posted.
you have provided details, and i was able to see them-as such no issues onwhat you posted, Please
 
I have one more question, more of a conceptual one: what is the advantage of operating the LCD in 4-bit mode rather than 8-bit mode besides reduction of the amount of pins used on the microcontroller?
 
ssylee said:
I have one more question, more of a conceptual one: what is the advantage of operating the LCD in 4-bit mode rather than 8-bit mode besides reduction of the amount of pins used on the microcontroller?

The only advantage is the reduction in the number of pins. The only disadvantage is slightly slower code. A lot of people don't connect the RW line to save 1 more pin and use a delay after each write to the LCD. Using 6 pins instead of 11 can be the difference between an 18 and a 28 pin pic.

Mike.
 
I'm using a 28-pin PIC. I also have 40 pin PICs available. How much slower code execution would 4-pin mode compared to 8-bit mode?
 
ssylee said:
I'm using a 28-pin PIC. I also have 40 pin PICs available. How much slower code execution would 4-pin mode compared to 8-bit mode?
Not even noticeable. You're already waiting constantly for the LCD anyway. They're pretty slow.
 
ssylee said:
I'm using a 28-pin PIC. I also have 40 pin PICs available. How much slower code execution would 4-pin mode compared to 8-bit mode?

Very little difference, it's the difference between,
Code:
		movfw	Data
		movwf	PortB

and,

Code:
		movfw	Data
		movwf	PortB
		bsf	PORTB,LCD_E
		bcf	PORTB,LCD_E
		swapf	Data,W
		movwf	PortB
		bsf	PORTB,LCD_E
		bcf	PORTB,LCD_E

So about 6 instructions per character. Completely irrelevant compared to the LCD internal timing which is 40uS for a character write.

Mike.
 
If I have want to data log something, should I use one microcontroller for the LCD and one for datalogging using a separate microcontroller?
 
It depends on the speed of logging. If it's less than a few 100 bytes per second then the pic would be able to do both. What are you logging?

Keep in mind that if you are writing to EEPROM then it takes around 6mS per byte.

Mike.
 
I've posted a routine for MPASM (18F4550) for the Unicorn kit that also includes the soft reset that is often ignored for a typical 16x2 LCD display, It's at the end of the Unicorn Assembly Instructions on my site.
Uses timed slow & safe 50ms delays to get it started but then uses the very fast busy flag in the main routine.
**broken link removed**
 
I haven't gotten it working yet (haven't gotten around to it). I'm still playing around with your example. I've noticed that your example uses a 4-bit interface. I am pondering of switching from an 8-bit interface to a 4-bit interface since I don't benefit much from using an 8-bit interface in terms of execution speed anyway.
 
wschroeder,

I have something that I don't understand in your delay loops in the examples. Why did you declare t0 in the parameters as type char rather than type int?

Also, I have yet to try your code on an actual LCD, but it is not working with the Oshon PIC 18 Simulator.
 
Last edited:
I have found out that my connections are screwed up. I'm currently fixing the hardware connections on the breadboard and update on the situation.
 
After fixing the hardware connections, I'm still having problems running my code which interfaces using the 8-bit mode.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top