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

CFAG320240cx sample code problem

Anthony Simpson

New member
Im using the CFAG320240cx trying to display the sample code supplied to me. but I'm getting this screen instead of the normal flash screen.


When I just write the text part of the code I get the same screen unless I clear the two splash screens with a write_data(0) command.

write_data(display[row][col]); to write_data(0);
This gives me this:


I haven't changed anything else and I'm rather confused. Any help would be appreciated.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.

Anthony Simpson

New member
Some more information:

I'm using an atmel stk600 development board with an atmega2560 chip (should be the same as 2561 with more memory and more pins). Once again any help would be appreciated.

Anthony Simpson

New member
Oh yeah one more change

Okay sorry I forgot, Atmel Studio 6 does not like prog_uchar.

const prog_uchar splash_CFAG320240CX_320_240_2[120][40]=....
After reading online it was suggested to just use const char

const char splash_CFAG320240CX_320_240_1[120][40]=...
That really is all the changes made. I'm still confused as to why it's not working.
I have no experience with the CFAG320240cx display, but maybe I can be of some help.

Since you started this thread "CFAG320240cx and CFA-10018 question" here, and you say
I'm using an atmel stk600 development board with an atmega2560 chip
I am assuming you have removed the LCD from the CFA-10018 and wired it to the stk600 board. Is this correct?

Based on that assumption:
trying to display the sample code supplied to me
Where are you getting the sample code mentioned here?

Have you wired the LCD for the correct cpu mode (using the J80/J68 jumpers) to be compatible with your code?

Okay sorry I forgot, Atmel Studio 6 does not like prog_uchar.
I have used "prog_uchar" in my avr code. It is defined in <pgmspace.h> in the avr include path. Are you including that header file? FYI, "pgm_read_byte()" and "pgm_read_word()" are macros in pgmspace.h to fetch a byte from flash instead of SRAM. By just using
const [B]char[/B] splash_CFAG320240CX_320_240_1[120][40]=...
, I wonder whether the splash data is being put in RAM or flash. Have you tried stepping with the debugger to see where the fetch is from?

Without knowing how you have the display wired to the dev board, or your actual code, its tough to guess what might be wrong. BTW, if you have any notion of posting your code, upload the file as an attachment rather than trying to put it into a "code" box.

Anthony Simpson

New member

You are correct I had the screen mounted on the CFA-10018 board and it worked fine. I took the screen off and wired it to the stk600 using the pin out sheet of the cfa-10018 wire for wire (connected pins on the CFAG that went to PortA and PortC on the 10018 to PortA and PortC on the stk600).

The sample code I am trying to run was given to me by someone at crystalfontz (coworker ordered and talked to someone, but now I'm doing the work so I'm not sure who it was). I have included a copy of the project in this reply.

I have avr/pgmspace.h included, but when I try to use prog_uchar it gives me "unknown type name 'prog_uchar'". I haven't tried using the debugger that's a good idea. I'll do that sometime today and see where it's trying to pull the splash from.

If I can provide any more information that will help just let me know. Thanks!


Anthony Simpson

New member
Thanks for your help Cosmic! I looked and it was trying to pull from RAM and wasn't finding anything so it was printing garbage. I did a little more research and i needed a PROGMEM in there to tell it to load into Program memory.

const char splash_CFAG320240CX_320_240_1[120][40]PROGMEM=
This fixed the problem and made it pretty.

Thanks again!