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

How initialize the CFAG320240

lcyepiz

New member
I need some example for the parameters of the CFGA320240,
i trying test whith this

it is correct?

lcd_writeControl(SYSTEM_SET);
lcd_writeData(0x38); // 0 0 IV 1 W/S M2 M1 M0
lcd_writeData(0x87); // FX
lcd_writeData(0x07); // FY
lcd_writeData(0x27); // C/R 320/8-1 = 39 = 0x27
lcd_writeData(0x38); // TC/R
lcd_writeData(0xEF); // LF
lcd_writeData(0x28); // APL
lcd_writeData(0x00); // APH
lcd_writeControl(SCROLL);
lcd_writeData(0x00);
lcd_writeData(0x00);
lcd_writeData(0xEF); // 240 - 1
lcd_writeData(0xB0);
lcd_writeData(0x04);
lcd_writeData(0xEF); // 240 - 1
lcd_writeData(0x00); // Don't care
lcd_writeData(0x00); // Don't care
lcd_writeData(0x00); // Don't care
lcd_writeData(0x00); // Don't care

lcd_writeControl(HDOT_SCR);
lcd_writeData(0x00);

lcd_writeControl(OVLAY);
lcd_writeData(0x00); // 0 0 0 OV DM2 DM1 MX1 MX0

lcd_writeControl(DISP_OFF);
lcd_writeData(0x00);

lcd_clear_text();
lcd_clear_graphics();

lcd_writeControl(CSRFORM);
lcd_writeData(0x00);
lcd_writeData(0x00);

lcd_writeControl(CSRDIR_RIGHT);

lcd_writeControl(DISP_ON);
lcd_writeData(0x16);

thank in advance
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Tech

Administrator
You would just want to follow the initilaize routine in the demo code:

http://www.crystalfontz.com/backlight/Demo_Code/CFAG320240C_WinTest.zip

Depending on the speed of your processor, you may need to have some delays at some points.

Code:
  //Idle the control lines & reset the display
  CLR_RES;
  CLR_E;
  CLR_A0;
  SET_CS;
  DATA(0);
  Sleep(10);
  SET_RES;
  Sleep(10);


//SYSTEM_SET:
  COM_W(0x40);
  DATA_W(0x30);
  DATA_W(0x87); //FX
  DATA_W(0x07); //FX
  DATA_W(0x27); //CR
  DATA_W(0x42); //TC/R
  DATA_W(0xEF); //L/F
  DATA_W(0x28); //APL
  DATA_W(0x00); //APH
 
//SCROLL:
  COM_W(0x44);
  DATA_W(0x00);
  DATA_W(0x00);
  DATA_W(0xEF); //L/F
  DATA_W(0x60); //SAD_2L
  DATA_W(0x09); //SAD_2H
  DATA_W(0xEF); //L/F
//  DATA_W(0x25); //SAD_3L
//  DATA_W(0x2F); //SAD_3H
  DATA_W(0x00); //SAD_3L
  DATA_W(0x00); //SAD_3H
  DATA_W(0x00);
  DATA_W(0x00);
//HDOT_SCR:
  COM_W(0x5A);
  DATA_W(0x00);  //NO SCROLL
//OVERLAY:
  COM_W(0x5B);
//  DATA_W(0x00);   //GRAPHIC & OR
  DATA_W(0x01);   //GRAPHIC & XOR
//  DATA_W(0x01F);   //"PRIORITY OR"
//CSR_FORM:
  COM_W(0x5D);
  DATA_W(0x07);
  DATA_W(0x87);
//CSR_DIR:
  COM_W(0x4C);

//DISP_ON:
  COM_W(0x59);
  DATA_W(0x14);

  Clear_Text_Layer();
  CLEAR_LAYER_2();


  int
    row,col;
  //CALL    POS2
  COM_W(0x46);
  DATA_W(0x60);
  DATA_W(0x09);

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

  CLR_A0;
  CLR_CS;
  for(row=0;row<240;row++)
    for(col=0;col<40;col++)
      {
      DATA(splash_CFAG320240C_320_240[row][col]);
      SET_E;
      CLR_E;
      }
  SET_CS;

  //CALL    POS1
  COM_W(0x46);
  DATA_W(0x00);
  DATA_W(0x00);
  //Clear loop
  COM_W(0x42);
  CLR_A0;
  CLR_CS;

  for(row=0;row<30;row++)
    for(col=0;col<40;col++)
      {
      DATA(SplashText_Screen[row][col]);
      SET_E;
      CLR_E;
      }
  SET_CS;
 
Top