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.

PIC 18F4550 2x8 LCD Character Display Assistance

Status
Not open for further replies.
First thing in the newhaven datasheet it specifies that to use 4 bit communiction you have to use D7-D4 of the character LCD and the other data pins are not connected. So, you don't need to ground the other connections. Also, the oscillator configuration, if you are using an external crystal is:

Code:
/48Mhz for USB configuration
#pragma config FOSC = HSPLL_HS    // Using 20 MHz crystal with PLL
#pragma config PLLDIV = 5 		  // Divide by 5 to provide the 96 MHz PLL with 4 MHz input
#pragma config CPUDIV = OSC1_PLL2 // Divide 96 MHz PLL output by 2 to get 48 MHz system clock
#pragma config USBDIV = 2 		  // USB clock comes from 96 MHz PLL output / 2
#pragma config VREGEN = ON 		  // Enables internal USB voltage regulator - necessary for USB communication

This based on a 20MHz crystal/resonator. Whichever crystal you are using you have to set the PLLDIV to a value that divides the crystal/resonator frequency to 4MHz. Also, you have to CPUDIV and USB DIV. Check the above comments for clarity.

Next thing I notice is that in the simulation you have D5 going to RA0. Why is this? I don't see an ADCON1 command that turn that pin to digital. See pgs. 262 of the pic18f4550 datasheet, which shows what hex value turns certain RA and RB pins to digital. For example, ADCON1=0x0F makes all of the analog pins digital (shown at the bottom of the table on pg. 262).

Also, I would checkout the "void init(void)" function I have posted in the code I am using. This is necessary to initialize the LCD so that you can send data and commands. In this function there are several commands that are time dependent based upon the LCD controller. I would check out the datasheet of the character LCD you are using (however most character LCDs are very similar to one another). Some provide psuedo code to help you out a bit.

I was able to get my project going thanks to Pommie and the pseudo code and information provided in the datasheet for the LCD module and the controller datasheet from Newhaven. So, I would check out any documentation that is available as well.

Aslo note that if you plan to use this with a uC operating above 8MHz, 100nF decoupling capacitors between VDD and VSS are a must.

Lastly, I'm not 100% sure what you have planned for your program (interfacing with temp sensor, etc), but I would start out with writing some simple text like "Hello World," and then testing the clear display commands, etc. So, start out with a clean project add in the basic essentials, and then once you have the LCD working go back to the code you have posted and continue implementing your project. It always best to troubleshoot things piece by piece and not all at once.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top