|
|
View previous topic :: View next topic |
Author |
Message |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
Has anyone used the Epson S1D13700?? |
Posted: Thu Nov 09, 2006 12:15 pm |
|
|
Hi,
I have just purchased a Crystalfontz CFAG320240CX (S1D13700) 320X240 LCD graphics display which "supposedly" is compatible with its predecessor controller (Epson SED1335) I believe that a simple driver for this one already exists in the CCS drivers list (SED1335.c) However the more I investigate into this, I find, that quite a few people on various newsgroups are saying that there are some very distinct differences in the command set and timing issues between these controllers. Because this is totally new territory for me, as I have never written any graphics drivers before, I wanted to pose the question within this group to see if anyone else has already tackled this issue, specially using the CCS compiler. As usual, any hints or advise is greatly appreciated. |
|
|
Eduardo____ Guest
|
S1D13700 driver |
Posted: Fri Dec 22, 2006 6:18 am |
|
|
There is a problem: The driver for SED1335 from CCS, don't work correctly with S1D13700. I have just corrected the problem. Here is the code for S1D13700:
Code: | /////////////////////////////////////////////////////////////////////////
//// SED13700.C ////
//// ////
//// Example drivers for the SED13700 LCD controller configurada ////
//// no modo gen鲩o de comunica磯 indireta(bus 8 bits, RW, RD, Ao)////
/////////////////////////////////////////////////////////////////////////
//// ////
//// glcd_init(mode) ////
//// * Must be called before any other function. ////
//// - mode can be ON or OFF to turn the LCD on or off ////
//// ////
//// glcd_pixel(x,y,color) ////
//// * Sets the pixel to the given color. ////
//// - color can be ON or OFF ////
//// ////
//// glcd_fillScreen(color) ////
//// * Fills the entire LCD with the given color. ////
//// - color can be ON or OFF ////
//// ////
/////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996,2003 Custom Computer Services ////
//// Modificado para S1d13700 por Eduardo Guilherme Brandt ////
//// 19/12/2006 ////
//// ڬt.Altera磯 21/12/2006 ////
/////////////////////////////////////////////////////////////////////////
////
//// Definiçµ¥s antes da carga do driver:
////
////
//// #define GLCD_WIDTH 320
//// #define GLCD_HEIGHT 240
//// #define GLCD_CHAR_WIDTH 8
//// #define GLCD_CHAR_HEIGHT 8
//// #define GLCD_RST PIN_XX //Apenas definir se n㯠tover resetado previamente(O driver faz o reset)
//// #define set_tris_lcd set_tris_d
//// #define input_lcd input_d
//// #define output_lcd output_d
//// #define GLCD_RD PIN_B5
//// #define GLCD_WR PIN_B1
//// #define GLCD_CS PIN_B2
//// #define GLCD_A0 PIN_B4
////
//// #define LARGE_LCD //O driver define automaticamente se linhas ou colunas>256pontos(Ex. 320x240pí¸¥ls)
////
/////////////////////////////////////////////////////////////////////////
#ifndef SED13700
#define SED13700
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 320
#define LARGE_LCD
#else
#if GLCD_WIDTH>256
#define LARGE_LCD
#endif
#endif
#ifndef GLCD_HEIGHT
#define GLCD_HEIGHT 240
#else
#if GLCD_WIDTH>256
#ifndef LARGE_LCD
#define LARGE_LCD
#endif
#endif
#endif
#ifndef GLCD_CHAR_WIDTH
#define GLCD_CHAR_WIDTH 8
#endif
#ifndef GLCD_CHAR_HEIGHT
#define GLCD_CHAR_HEIGHT 8
#endif
//#ifndef GLCD_RST
//#define GLCD_RST PIN_C3
//#endif
#ifndef set_tris_lcd
#define set_tris_lcd set_tris_d
#endif
#ifndef input_lcd
#define input_lcd input_d
#endif
#ifndef output_lcd
#define output_lcd output_d
#endif
#ifndef GLCD_RD
#define GLCD_RD PIN_B5
#endif
#ifndef GLCD_WR
#define GLCD_WR PIN_B1
#endif
#ifndef GLCD_CS
#define GLCD_CS PIN_B2
#endif
#ifndef GLCD_A0
#define GLCD_A0 PIN_B4
#endif
#ifndef ON
#define ON 1
#endif
#ifndef OFF
#define OFF 0
#endif
#define _t1 1
#define _t2 2
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// The following defines setup the memory used by different regions
// Currenty one text area is defined at the beginning of memory
// and a graphics area follows immediately after
/////////////////////////////////////////////////////////////////////////
#define GLCD_TEXT_ADDR 0x0000
#define GLCD_GRAPHICS_ADDR GLCD_WIDTH * GLCD_HEIGHT / 64
#define GLCD_GRAPHICS_ADDR_END GLCD_GRAPHICS_ADDR + (GLCD_WIDTH * GLCD_HEIGHT / 8)
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
#if GLCD_CHAR_WIDTH < 9
#define GLCD_CR (GLCD_WIDTH/8 - 1)
#else
#define GLCD_CR (GLCD_WIDTH/4 - 2)
#endif
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
#define TGLCD_COMMAND output_high(GLCD_A0);
#define TGLCD_DATA output_low(GLCD_A0);
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
int8 glcd_readByte();
void glcd_sendByte(int8 data);
void glcd_fillScreen(int1 color);
void glcd_fillScreenText(char c);
void setCursorAddress(int16 addr);
void glcd_pixel(int16 x, int16 y, int1 color);
void glcd_sendCMD(int8 cmd);
int16 getCursorAddress();
int8 getData(int16 addr);
int8 getStatus();
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
void glcd_systemSetup();
void glcd_scrollSetup();
void glcd_overlaySetup();
void glcd_power(int1 mode);
void glcd_cursorDirection(int8 dir);
void glcd_cursorForm(int8 width, int8 height);
void setData(int16 addr, int8 data);
/////////////////////////////////////////////////////////////////////////
#define GLCD_CMD_SYSTEM 0x40 // General system settings
#define GLCD_CMD_SLEEP 0x53 // Enter into standy mode
#define GLCD_CMD_DISP_OFF 0x58 // Turn the display off
#define GLCD_CMD_DISP_ON 0x59 // Turn the display on
#define GLCD_CMD_SCROLL 0x44 // Setup text and graphics address regions
#define GLCD_CMD_CSR_FORM 0x5D // Set cursor size
#define GLCD_CMD_CSRDIR_RIGHT 0x4C // Cursor moves right after write to display memory
#define GLCD_CMD_CSRDIR_LEFT 0x4D // Cursor moves left after write to display memory
#define GLCD_CMD_CSRDIR_UP 0x4E // Cursor moves up after write to display memory
#define GLCD_CMD_CSRDIR_DN 0x4F // Cursor moves down after write to display memory
#define GLCD_CMD_CGRAM_ADDR 0x5C // Configure character generator RAM address
#define GLCD_CMD_HDOT_SCR 0x5A // Set horizontal scroll rate
#define GLCD_CMD_OVERLAY 0x5B // Configure how layers overlay
#define GLCD_CMD_SET_CSR_ADDR 0x46 // Set the cursor address
#define GLCD_CMD_GET_CSR_ADDR 0x47 // Read the cursor address
#define GLCD_CMD_DISPLAY_WRITE 0x42 // Write to display memory
#define GLCD_CMD_DISPLAY_READ 0x43 // Read from display memory
// Purpose: Initialize the controller
// Inputs: The initialization mode
// OFF - Turns the LCD off
// ON - Turns the LCD on
void glcd_init(int1 mode)
{
// Initialze some pins
#ifdef GLCD_RST //Sup?e que o dispositivo ja foi resetado
output_high(GLCD_RST);
#endif
output_high(GLCD_CS);
output_high(GLCD_RD);
output_high(GLCD_WR);
glcd_systemSetup();
glcd_scrollSetup();
glcd_overlaySetup();
glcd_power(OFF);
glcd_cursorForm(4, 6);
glcd_fillScreen(OFF);
glcd_fillScreenText(' ');
glcd_power(mode);
glcd_cursorDirection(GLCD_CMD_CSRDIR_RIGHT);
}
// Purpose: Turn a pixel on a graphic LCD on or off
// Inputs: x - the x coordinate of the pixel
// y - the y coordinate of the pixel
// color - ON or OFF
void glcd_pixel(int16 x, int16 y, int1 color)
{
int8 data;
int16 addr;
// Calculate the byte address containing the pixel
addr = GLCD_GRAPHICS_ADDR + (GLCD_WIDTH/8 * y + x/8);
// Read the byte of data at the address
data = getData(addr);
// Turn the pixel on or off
if(color == ON)
bit_set(data, 7 - x%8);
else
bit_clear(data, 7 - x%8);
/* setData(0x0000, 49);
setData(0x0001, 50);
setData(0x0002, 51); uuuuuuuuuuuuuu
setData(0x0003, 52);
setData(0x0100, 49);
setData(0x0101, 50);
setData(0x0102, 51);
setData(0x0103, 52); */
// addr = getCursorAddress(); //hehe
// data = getData(0x0103);
// Write the new data byte to display memory
setData(addr, data);
}
// Purpose: Initialize the display environment
void glcd_systemSetup()
{
glcd_sendCMD(GLCD_CMD_SYSTEM); // Setup the system
TGLCD_DATA // Set for data
glcd_sendByte(0x30); // No offset
glcd_sendByte(0x7F + GLCD_CHAR_WIDTH); // Set character width
glcd_sendByte(GLCD_CHAR_HEIGHT - 1); // Set character height
glcd_sendByte(GLCD_CR); // Display line address range
glcd_sendByte(0x2F); // TC/R
glcd_sendByte(GLCD_HEIGHT - 1); // Number of lines per frame
glcd_sendByte(GLCD_CR + 1); // Horizontal address range LSB (APL)
glcd_sendByte((GLCD_CR + 1) / 0xFF); // Horizontal address range MSB (APH)
}
// Purpose: Set the scroll start address and
// the size of a scroll block
void glcd_scrollSetup()
{
// Currently setup for a text and graphics layer
glcd_sendCMD(GLCD_CMD_SCROLL); // Setup scrolling
TGLCD_DATA // Set for data
glcd_sendByte(GLCD_TEXT_ADDR); // SAD1L
glcd_sendByte(GLCD_TEXT_ADDR / 0xFF); // SAD1H
glcd_sendByte(GLCD_HEIGHT - 1); // SL1
glcd_sendByte(GLCD_GRAPHICS_ADDR); // SAD2L
glcd_sendByte(GLCD_GRAPHICS_ADDR / 0xFF); // SAD2H
glcd_sendByte(GLCD_HEIGHT - 1); // SL2
glcd_sendByte(0x00); // SAD3L
glcd_sendByte(0x00); // SAD3H
glcd_sendByte(0x00); // SAD4L
glcd_sendByte(0x00); // SAD4H
glcd_sendCMD(GLCD_CMD_HDOT_SCR); // Horizontal scroll rate
TGLCD_DATA // Set for data
glcd_sendByte(0x00); // Horizontal pixel shift is 0
}
// Purpose: Setup the overlay functionality for combining
// layers of text and graphics, or multiple
// graphics layers
void glcd_overlaySetup()
{
// Currently setup for a single graphics layer
glcd_sendCMD(GLCD_CMD_OVERLAY); // Text / graphic overlay mode
TGLCD_DATA // Set for data
glcd_sendByte(0x09); // Area 1 text, others graphics
// Text XOR Graphics
}
// Purpose: Turn the display on or off
// Inputs: ON to turn on or OFF to turn off
void glcd_power(int1 mode)
{
if(mode == ON)
{
glcd_sendCMD(GLCD_CMD_DISP_ON); // Turn the display on
}
else
{
glcd_sendCMD(GLCD_CMD_DISP_OFF); // Turn the display off
}
TGLCD_DATA // Set for data
glcd_sendByte(0x14);
}
// Purpose: Set the direction the cursor moves after
// writing to dispaly memory
// Inputs: Use one of the following to set the direction:
// GLCD_CMD_CSRDIR_RIGHT
// GLCD_CMD_CSRDIR_LEFT
// GLCD_CMD_CSRDIR_UP
// GLCD_CMD_CSRDIR_DOWN
void glcd_cursorDirection(int8 dir)
{
glcd_sendCMD(dir);
}
// Purpose: Set the size of the cursor
// Inputs: 1) The width in pixels - 1 Valid numbers: (0 - 15)
// 2) The height in pixels - 1 Valid numbers: (1 - 15)
void glcd_cursorForm(int8 width, int8 height)
{
glcd_sendCMD(GLCD_CMD_CSR_FORM); // Cursor form and size
TGLCD_DATA // Set for data
glcd_sendByte(width);
glcd_sendByte(0x80 + height);
}
// Purpose: Fill a graphics layer passed in color
// Works much faster than drawing a rectangle to fill the screen
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
void glcd_fillScreen(int1 color)
{
int16 i;
setCursorAddress(GLCD_GRAPHICS_ADDR);
glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
TGLCD_DATA
for(i = GLCD_GRAPHICS_ADDR; i < GLCD_GRAPHICS_ADDR_END; ++i)
{
glcd_sendByte(0xFF * color);
}
}
// Purpose: Fill a text layer with a the passed in character
// Works much faster than drawing a rectangle to fill the screen
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
void glcd_fillScreenText(char c)
{
int16 i;
setCursorAddress(GLCD_TEXT_ADDR);
glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
TGLCD_DATA
for(i = GLCD_TEXT_ADDR; i < GLCD_GRAPHICS_ADDR; ++i)
{
glcd_sendByte(c);
}
}
// Purpose: Write a byte of data
// Inputs: The byte of data to write
void glcd_sendByte(byte data)
{
output_lcd((data));
output_low(GLCD_CS);
delay_cycles(_t1);
output_low(GLCD_WR);
delay_cycles(_t2);
output_high(GLCD_WR);
output_high(GLCD_CS);
}
// Purpose: Read a byte of data
// Outputs: The byte of data
int8 glcd_readByte()
{
byte data;
set_tris_lcd(0xFF);
output_low(GLCD_CS);
delay_cycles(_t1);
output_low(GLCD_RD);
delay_cycles(_t2);
data = input_lcd();
output_high(GLCD_RD);
output_high(GLCD_CS);
return data;
}
// Purpose: Get the status
// Outputs: The status in an 8 bit integer
int8 getStatus()
{
int8 status;
TGLCD_DATA
output_low(GLCD_CS);
output_low(GLCD_RD);
delay_us(_t1);
status = input_lcd();
output_high(GLCD_RD);
output_high(GLCD_CS);
return status;
}
// Purpose: Get the current address of the cursor
// Outputs: A 16 bit integer containing the cursor address
int16 getCursorAddress()
{
int16 addr;
glcd_sendCMD(GLCD_CMD_GET_CSR_ADDR);
TGLCD_COMMAND //CORRECAO - MODIFIED LINE
// TGLCD_DATA; //CORRECAO
*(int8*)(&addr ) = glcd_readByte(); // Read low part
*(int8*)(&addr + 1) = glcd_readByte(); // Read high part
return addr;
}
// Purpose: Set the cursor address
// Inputs: A 16 bit integer containing the new cursor address
void setCursorAddress(int16 addr)
{
glcd_sendCMD(GLCD_CMD_SET_CSR_ADDR);
TGLCD_DATA
glcd_sendByte(*(int8*)(&addr ));
glcd_sendByte(*(int8*)(&addr + 1));
}
// Purpose: Get a byte of data from the display at the address
// Inputs: A 16 bit integer containing the address
// Outputs: An 8 bit integer with the read data
int8 getData(int16 addr)
{
setCursorAddress(addr);
glcd_sendCMD(GLCD_CMD_DISPLAY_READ);
TGLCD_COMMAND //CORRECAO - MODIFIED LINE
// TGLCD_DATA //CORRECAO
return glcd_readByte();
}
// Purpose: Set a byte of display data at an address
// Inputs: 1) A 16 bit address
// 2) 8 bits worth
void setData(int16 addr, int8 data)
{
setCursorAddress(addr);
glcd_sendCMD(GLCD_CMD_DISPLAY_WRITE);
TGLCD_DATA
glcd_sendByte(data);
}
// Purpose: Send an 8 bit command
// Inputs: The command to send
void glcd_sendCMD(int8 cmd)
{
TGLCD_COMMAND
glcd_sendByte(cmd);
}
#endif |
Don't forget to reset the Lcd before (#define GLCD_RST PIN_XX)
Get the code, and enjoy it! |
|
|
Guest
|
|
Posted: Fri Dec 22, 2006 6:57 am |
|
|
Thank you Eduardo...appreciate your help!
carlos |
|
|
jvadillo
Joined: 10 May 2007 Posts: 1 Location: Engineer
|
SED1335 and S1D13700 software incompatibilities |
Posted: Thu May 10, 2007 1:52 am |
|
|
Hello all,
I discovered a slight difference that may cause some headache for those who are programming the CGRAM of the S1D13700.
I have a board that was connected to a SED1335 (it was a screen from Crystal Clear Technologies. CCT G2432X15), but as this IC became obsolete by end 2005, I had to move to an updated version of this screen (G2432X17).
In the SED1335, bit M1 of the SYSTEM_SET register could be selected to have D6 correction over the CGRAM only, allowing the placement of the configurable character mask in a coninuous memory space.
However, in the S1D13700, the D6 correction applies to ALL, and if you use this "feature", you will have all your character codes partially shifted out, ending in a sort of ASCII mixture.
In the first S1D13700 technical manual, it was asserted that bit M1 could be configured in the same way as the SED1335. Mysteriously, this feature disappeared in subsequent revisions. The old M1 bit was described as "reserved", and it should be set to 0.
So, if you are using an SED1335 and you are setting a 1 to M1 bit of the SYSTEM_SET register, you will have to do a change in your software when moving to the S1D13700.
Regards,
Juan Ramón _________________ Juan Ramón Vadillo
www.jvadillo.com
Looking for oscilloscopes? Check here: http://jvadillo.googlepages.com |
|
|
shalts
Joined: 20 Oct 2006 Posts: 17 Location: Ankara
|
Here is the code for S1D13700: |
Posted: Sat Nov 07, 2009 3:37 pm |
|
|
Hi Eduardo,
Today I have found your post here and was very glad to find it . I have a TOPWAY LM2088E with S1D13700 (I think) (there is EPSON D1370002A1 written on the chip)
I have made the hardware as;
Pin_B5 to RD
Pin_B1 to WR
Pin_B2 to CS
Pin_B4 to A0
Pin_C3 to RST
pin_D0 to DB0
.
.
Pin_D7 to DB7
I am using a PIC18F452. I included your "SED13700.C " into my code. But when I compile it, the CCS compiler halts, freezez. Then I need to close the compiler and restart.
When I just compile my code without including the SED13700.C the CCS compiler works fine. but that time of course I have no LCD driver.
have any idea ? I couldnt seen even a dot on my new LCD yet please help if you can... I should be doing something wrong but I couldnt find.
Regards, _________________ Murat Shalt Unal |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Sun Nov 08, 2009 11:38 am |
|
|
I'm disappointed that this controller is only good for fairly small sizes of display. I've got a couple of 640x480 RGB panels that I'd love to get into use, but it would take a serious memory/driver system to get them operating. I can imagine a PIC just telling the graphic system what to do, though, if the mechanics of running the display were handled by something else. |
|
|
Modus Guest
|
|
Posted: Thu Feb 11, 2010 10:45 am |
|
|
Hi,
I have taken Eduardo's code too. XD. But I have some troubles. The display don't show anything. I have a DISPLAYTECH 240320G LCD, and I would like to know what are the differences between SED1335 and S1D13700 to check the library.
Should I change the system_setup parameters or is standard for all the LCD with S1D13700 chip.
Thanks |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|