Trouble CFAG240128L - PSoC

ctorres

New member
I'm trying to use a graphic LCD (CFAG240128L) to display some data from PSoC (CY8C27XXX). I found a program for to drive the Graphic LCD with a AVR but I don't know how adapt it for PSoC http://en.radzio.dxp.pl/t6963/ . I find a post in psocdeveloper forum with code for T6963C too but I don't know how do it works... http://www.psocdeveloper.com/forums/viewtopic.php?t=1020&highlight=t6963

I tried to use the 240128L_Wintest but doesn't work. I run BMP2ASM and only appear a msdos windows and close it immediately.

If anyone had work with this LCD or something similar I'd be very pleased to help me.

Help me please!

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

CF Tech

Administrator
BMP2ASM is just a little DOS utility to read in a bitmap file and write out the data to initialize an array to show that image in the Wintest program. You do not need to run it, since the WinTest example already has the bitmaps as initialized arrays.

The WinTest programs are just quick utilities that we put together to photograph the LCDs. Please read the post here: https://forum.crystalfontz.com/showthread.php?t=3257

Working with these graphic LCDs is quite a job. It is an order of magnitude more difficult than the character displays, which are in turn more difficult than the USB or serial displays.

In your particular situation, I think you are making a lot of work for yourself using the PSoC. Use an Atmel ATmega2561 and then you could dispense with the external memory, and have enough power to work the LCD without being up against the wall all the time. Even scrapping the processor at this "late" stage would probably get the project completed more quickly. That is your call though.

The controller is a Toshiba T6963. Here is the full data sheet:
http://www.crystalfontz.com/products/128128a/Toshiba_t6963CFG.pdf

You may be able to find some T6963 code for the PSoC that is already ported:

http://www.google.com/search?q=t6963+psoc

This is the only section you need from the sample code:
Code:
ubyte control;  //value of "*port_control_address"

#define DATA_ADDR (port_data_address)
#define CONT_ADDR (port_control_address)
  
//inverted at the port
#define CLR_CE (DlPortWritePortUchar(CONT_ADDR,(control|=0x01)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
#define SET_CE (DlPortWritePortUchar(CONT_ADDR,(control&=~0x01)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)

//inverted at the port
#define CLR_RD (DlPortWritePortUchar(CONT_ADDR,(control|=0x02)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
#define SET_RD (DlPortWritePortUchar(CONT_ADDR,(control&=~0x02)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
  
//straight at the port
#define SET_RW (DlPortWritePortUchar(CONT_ADDR,(control|=0x04)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
#define CLR_RW (DlPortWritePortUchar(CONT_ADDR,(control&=~0x04)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)

//inverted at the port
#define SET_CD  (DlPortWritePortUchar(CONT_ADDR,(control&=~0x08)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
#define CLR_CD  (DlPortWritePortUchar(CONT_ADDR,(control|=0x08)));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)

//#define SDATA(x) (DlPortWritePortUchar(DATA_ADDR,(x)));(Sleep(0));(Sleep(0));(Sleep(0));(Sleep(0))
#define DATA(x) (DlPortWritePortUchar(DATA_ADDR,(x)));(Sleep(0));(Sleep(0));(Sleep(0));(Sleep(0));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)
#define RDATA(x) (DlPortReadPortUchar(DATA_ADDR));(Sleep(0));(Sleep(0));(Sleep(0));(Sleep(0));Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0);Sleep(0)

void DATA_W(unsigned char data)                        
{
	CLR_CD;
	CLR_CE;
	CLR_RW;
	DATA(data);
	SET_CE;
	SET_RW;
}
//
uchar DATA_R()
{
    unsigned char data;
	CLR_CD;
	CLR_CE;
	CLR_RD;
	data = RDATA(data);//LcmDataPort;
	SET_CE;
	SET_RD;
    return data;
}
//read status
uchar Read_Status()
{
    unsigned char data;
	CLR_CD;
	CLR_CE;
	CLR_RD;
	data = RDATA(data);//LcmDataPort;
	SET_CE;
	SET_RW;
    return data;
}
//
void COM_W(unsigned char command)                  
{
	SET_CD;
    CLR_CE;
	CLR_RW;
	DATA(command);
    SET_CE;
	SET_RW;
}


void CheckRWCD(void)
{
    // while((LcmReadStatus() & 0x03) != 0x03);      //
}
//
void CheckAutoWrite(void)
{
   //  while((LcmReadStatus() & 0x08) == 0);      //
}
//
void CheckScreen(void)
{      
   //  while(LcmReadStatus() & 0x40);      //
}
//
void LcmWriteData(uchar uData)                        
{
	CLR_CD;
	CLR_CE;
	CLR_RW;
	DATA(uData);
	SET_CE;
	SET_RW;
}
//
uchar LcmReadData( void )
{
    uchar uData;
	CLR_CD;
	CLR_CE;
	CLR_RD;
	uData = RDATA(uData);//LcmDataPort;
	SET_CE;
	SET_RD;
    return uData;
}
//read status
uchar LcmReadStatus( void )
{
    uchar uData;
	CLR_CD;
	CLR_CE;
	CLR_RD;
	uData = RDATA(uData);//LcmDataPort;
	SET_CE;
	SET_RW;
    return uData;
}
//
void WriteCommand(uchar Command)                  
{
	SET_CD;
    CLR_CE;
	CLR_RW;
	DATA(Command);
    SET_CE;
	SET_RW;
}
//
void DelayKey(unsigned char)
{
	Sleep(2);
}

//
void LcmWriteCommand(uchar Command)                  
{
     CheckRWCD();     
     WriteCommand(Command);
}
//write 1 data command
void LcmWriteCommandWith1Par(uchar Parameter,uchar Command)
{
     CheckRWCD();                        
     LcmWriteData(Parameter);
     CheckRWCD();
     WriteCommand(Command);
}
//WRITE 2 data COMMAND 
void LcmWriteCommandWith2Par(uchar Parameter1,uchar Parameter2,uchar Command)
{
     CheckRWCD();                       
     LcmWriteData(Parameter1);
     CheckRWCD();
     LcmWriteData(Parameter2);
     CheckRWCD();
     WriteCommand(Command);
}
//LCM INITIALIZATION
void LcmInit( void )
{
     LcmWriteCommandWith2Par(0x00,0x00,0x40);      //
     LcmWriteCommandWith2Par(LcmLengthDots/8,0x00,0x41);      //
     LcmWriteCommandWith2Par(0x00,0xC0,0x42);      //address 0x0800
     LcmWriteCommandWith2Par(LcmLengthDots/8,0x00,0x43);      
     LcmWriteCommand(0xA0);                  //CURSUR 8x1
     LcmWriteCommand(0x81);                  //Xor
     LcmWriteCommand(0x9C);                  //TURN TEXT AND GRAPHIC ON
}
It is important to get the macros at the top right "CLR_RD", "SET_RD". Those will change for every processor. Do not worry about the sleeps, that is an artifact of not having good low-level control in a user application under Windows.

Thant code should get the display initialized, porting this should put up a bitmap:
Code:
void DisplayOneBmp(uchar *puts)
{
     uchar i,j;
     uint  X=0;
     LocateXY(0,0,Graphic);
     LcmWriteCommand(0xB0);                  //auto write
     for(i=0;i<LcmWidthDots;i++)
     {
          for(j=0;j<LcmLengthDots/8;j++)
           {
                 LcmWriteData(puts[X]);
                 X++;
           }
     }
     LcmWriteCommand(0xB2);                  //inject write
}
The code in those wintest programs is what we use to power up the modules for photographs, so we know it does work, but it is typically not very pretty.
 
Top