• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

Code & Schematic for CFAG320240CX with PIC18F

bfmitch

New member
Specifically, I'm using a CFAG320240CX-TFH-T.

I had some problems, and spent a lot of time, getting this guy going. I looked at sample code that Crystalfontz sent me and the code from PlazmaFox. Thanks!

The main reason for my problems was that I was using a 3.3v microcontroller (LPC2138) at first. It didn't work with two different displays. I believe it was due to the 3.3v signal levels. I tried running the LCD at 3.3 volts with no luck. I switched to the PIC18F4520 at 5v and it was all good.

Anyway, to help others who might want to see yet another example I'm including Example.zip and a PDF of the schematic.

Note that I am using 12v to drive the backlight so that my 5v regulator doesn't have to work as hard (and get as hot). If you use 9v or 5v you'll need different resistors. I'm using two 100 ohm, 1 watt resistors in parallel to get 50 ohms and the correct wattage. The backlight is controlled by a PWM signal from the PIC driving a logic level MOSFET. The backlight can be set to one of 10 different levels using push buttons. The backlight setting is stored in the EEPROM and recalled after a reset.

Remember that this code is an excerpt. You may have to make some changes to the main code to get it to compile and run. The driver files (glcd.c, glcd.h) are just the way I use them.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

Attachments

Last edited:

patR1

New member
great thanks for that i am using the PIC18F4550 an i am just starting a lcd connection. I just hope i have enough spare pins on this controller for an lcd screen. As i cant use any of the AN1.. pins or the usb pins.
 

Mark Weir

New member
Zip File

Hi There,

I would really like to check out your work with this GLCD and the PIC 18 but I can not open your zip file
Can you help please.

Cheers

Mark Weir

New Zealand
 

bfmitch

New member
Mark,

I'm using WinZip v10. I just downloaded the zip file and it opened OK.

If you still can't get it to work let me know an email address where I can send the source files. There are only 3 files.
 

reider

New member
I think there have been some instances where certain browsers have caused problems with downloads. Please try an alternative browser where possible. If this is not the situation then I apologise, I think it is in this instance though. Firefox is free to download and doesn`t seem to present a problem.

Reider
 

oit_tyler

New member
First of all, we are using MPLAB 7.62. I realize this post was over a year ago, but we are attempting to initiliaze this LCD to get it working with our PIC28f4520.

We are getting "syntax" errors on multiple lines in our header file. These 3 lines are an example:

int8 Hi ( int16 w );
int8 Lo ( int16 w );
void lcd_DataWrite ( int8 );

On the third line, if I comment "int8" out of the argument then it no longer has a problem. It seems like if this code worked for you, it should work for us.

Could use some feedback on this.
 

bfmitch

New member
First of all, we are using MPLAB 7.62. I realize this post was over a year ago, but we are attempting to initiliaze this LCD to get it working with our PIC28f4520.

We are getting "syntax" errors on multiple lines in our header file. These 3 lines are an example:

int8 Hi ( int16 w );
int8 Lo ( int16 w );
void lcd_DataWrite ( int8 );

On the third line, if I comment "int8" out of the argument then it no longer has a problem. It seems like if this code worked for you, it should work for us.

Could use some feedback on this.
I was using the CCS compiler under MPLAB. You'll have to change the prototypes to work with whatever compiler you are using. I've never used the Microchip C compiler so I don't know how they declare things.

Your compiler might have built-ins for getting the high and low unsigned bytes from a 16 bit unsigned word parameter. CCS does, but I didn't use them for some reason. (It probably made sense at the time.) lcd_DataWrite takes an unsigned byte as a parameter and returns nothing.
 

Fer

New member
hi agin, i did all that you said, but my lcd dont works... i m using te same compiler and the PIC18F458, but nothings happened, check out my code
 

Attachments

bfmitch

New member
I'll try to find a chance tomorrow to take a look. For now, you might check your fuses and make sure you're running at the same frequency. I've never used the 458, but I used to use the 452. It's fuses are different than the 4520 I used in the example code.
 

Fer

New member
Hi, did you check out the code? look i have a PIC18F4550, i want to know if it works like PIC18F4520. trhx a lot
 

bfmitch

New member
I haven't had a chance to check the code and I'm going to be out for the next week and the week after that.

If I remember correctly the 18F4550 has the USB interface in it and because of that the fuses that control the actual running frequency are different.

I suggest you make a test version of the code and make sure the PIC is running at the same frequency as the example.

Sorry I can't be much more help now. Time is not being good to me.
 
Top