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

PIC18f4520 CFAG320240C only writes once

LCD > ME

New member
I have the CFAG320240C display with the Espon controller... using it with the PIC18f4520.

I have it initialized, one text and one graphics layer. I can write a sentence, fill the whole screen with a character, etc, but I can only write to the screen once. If I want to write to it starting at a particular position, then try to do another write after that it doesn't work!

I'll post code if it will help, but I was just wondering if there is something that needs to be reset, cleared, etc before I can do another write. Also what do I use the WAIT line for, because I'm not using it right now and I didn't see it used in the initialization examples...

Thanks!

PS: I'll be posting the code once I get it working completely anyway just as a reference for people who got as frustrated as I did trying to get this thing initialized :/
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
In our demo code, when we show an image, it is a "second write" after initialization. So I think something along these lines should work:
Code:
void CCFAG320240CX_WinTestDlg::OnVstripesMono() 
  {
  int
    row,col;
  //CALL    POS2
  COM_W(0x46);
  DATA_W(0x60);
  DATA_W(0x09);

  //Dump the bitmap to the display
  COM_W(0x42);

  CLR_A0;
  CLR_CS;
  for(row=0;row<240;row++)
    for(col=0;col<40;col++)
      {
      DATA(0xAA);
      SET_E;
      CLR_E;
      }
  SET_CS;
  }
(From "CFAG320240CX_WinTest", in the CFAG320240CX_WinTestDlg.cpp file here:
https://forum.crystalfontz.com/showthread.php?t=3257)
 

LCD > ME

New member
Thanks, as far as I know I have done the actual write properly... I haven't started doing anything with the graphics layer yet aside from write 0x00 to the whole display. Should I be using the WAIT line at all?

Ill post code when I get to the computer I am working on...
 

CF Tech

Administrator
To my knowledge, the wait can be used to optimize the throughput from the processor to the display.

For now, I would not worry about it. Just get things working with generous delays, then once things are working right (though maybe a bit slow) you can try using the wait to eliminate the delays and speed things up.

But that is an optimization. You need to get to functional before worrying about optimal.
 

LCD > ME

New member
OK I got it working

I have the display working now. I displayed the test tractor just fine, and I can write text over it... One thing I can't seem to figure out though is how the addressing for the cursor to write text works I guess. It seemed to be that the cursor would just wrap around the screen, so if I wanted the cursor to be on the second row, I would offset the starting cursor address at 40 (0x28)... adding 40 to the starting cursor address should give me the beginning of any given row yeah? I cant seem to get it to work this way...
 
Top