View previous topic :: View next topic |
Author |
Message |
modus83
Joined: 13 Apr 2010 Posts: 7
|
Displaytech 240320G Driver (SED13700) |
Posted: Tue Apr 13, 2010 1:44 pm |
|
|
Hi!
I'm finishing my career project and I have to use this GLCD.
But It doesn't show anything. I have check the connections a lot of times and I think this is not the problem.
I use this library:
http://www.ccsinfo.com/forum/viewtopic.php?t=28830&highlight=s1d13700
But it doesn´t works!!
I have SED1335.c also. Do anybody know what are the exactly changes to do in this library to get SED13700?. (I know M1 bit System_set register but I don´t know what changes I have to do).
O someone who has sed13700 library tested....
Please somebody help me!
It´s very important..
(Sorry for my english....) |
|
|
modus83
Joined: 13 Apr 2010 Posts: 7
|
|
Posted: Wed May 19, 2010 11:09 am |
|
|
Nobody????
I'm so worried. Someone who has SED13700.c code?
Any example?? Please, help
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 19, 2010 12:44 pm |
|
|
Post your compiler version. You can find it at the top of the .LST file in
your project directory. The version number is in this format: x.xxx
If your version is 4.021 or later, then the following routines are bugged
and will not work with those versions. The lines shown in bold are the
problem. Before vs. 4.021, CCS assumed all pointers were byte pointers
with respect to doing pointer arithmetic. But this is not the C standard.
They fixed this problem starting with vs. 4.021. The side effect is that
old code is "broken" when you use it with vs. 4.021 or later. It needs
to be edited and fixed.
Quote: |
// 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));
} |
Here are the new, edited routines. These will work with compiler
vs. 4.021 and later:
Code: |
// 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(); // *** Fixed pointer arithmetic
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)); // *** Fixed pointer arithmetic
}
|
|
|
|
modus83
Joined: 13 Apr 2010 Posts: 7
|
|
Posted: Thu May 20, 2010 7:52 am |
|
|
Thank you so much!
I have 4.058 compiler version....so...I'm going to update with your code.
The modifications are correct (CORREÇAO)?
I have changed the C/R and TC/R parameters because my screen is 240x320, not 320x240 pixels.... and I'm using a 20 Mhz crystal.
Anyway, I think that it is not going to work.....
I only want that one pixel puts ON!!!
Thank you for answer.... |
|
|
modus83
Joined: 13 Apr 2010 Posts: 7
|
|
Posted: Tue May 25, 2010 12:37 pm |
|
|
Hi,
Your solution does not work. The issue is that it shows no
pixel ... nothing. The microcontroller is working properly (18F2550) because
the test LED turns on, but the screen does nothing ...
I have checked a thousand times the connections and everything seems fine ...
I'm going crazy ... what surprises me is not displaying
absolutely nothing ...
I'm going to post the code if anyone can help ....
Code: |
#ifndef SED13700
#define SED13700
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 320
#else
#if GLCD_WIDTH>256
#define LARGE_LCD
#endif
#endif
#ifndef GLCD_HEIGHT
#define GLCD_HEIGHT 240
#else
#if GLCD_HEIGHT>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_C0
#endif
#ifndef set_tris_lcd
#define set_tris_lcd set_tris_b
#endif
#ifndef input_lcd
#define input_lcd input_b
#endif
#ifndef output_lcd
#define output_lcd output_b
#endif
#ifndef GLCD_RD
#define GLCD_RD PIN_A2
#endif
#ifndef GLCD_WR
#define GLCD_WR PIN_A1
#endif
#ifndef GLCD_CS
#define GLCD_CS PIN_A3
#endif
#ifndef GLCD_A0
#define GLCD_A0 PIN_A0
#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_low (GLCD_RST);
delay_ms (1);
output_high(GLCD_RST);
delay_ms (1);
#endif
output_high(GLCD_CS);
output_high(GLCD_RD);
output_high(GLCD_WR);
glcd_systemSetup();
glcd_scrollSetup();
glcd_overlaySetup();
glcd_power(OFF);
glcd_fillScreenText(' ');
glcd_fillScreen(OFF);
glcd_cursorForm(4, 6);
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);
// 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(0x9A); // TC/R (Antes ponía 2F)
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(0x00); // 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(0x16);
}
// 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); //POR MI
}
// Purpose: Read a byte of data
// Outputs: The byte of data
int8 glcd_readByte()
{
byte data;
set_tris_lcd(0xFF);
output_high(GLCD_WR); //POR MI
output_low(GLCD_CS);
delay_cycles(_t1);
output_low(GLCD_RD);
data = input_lcd(); //POR MI cambio orden
delay_cycles(_t2);
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(); // *** Fixed pointer arithmetic
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)); // *** Fixed pointer arithmetic
}
// 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
|
Are ok the MODIFICATION LINES (getData and getAdress)??
The main program is:
Code: |
#include <18f2550.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOMCLR
#use delay(clock=20000000)
#include "SED13700_JORDI.c"
#include "graphics.c"
void main() {
delay_ms (100);
glcd_init(ON);
while (TRUE)
{
glcd_rect (0,0,100,100,1,1);
delay_ms (1000);
glcd_fillscreen (0);
}
}
|
Thank you so much for your help, friends!!
Bye |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 25, 2010 2:48 pm |
|
|
I assume this is the data sheet for your LCD.
http://www.displaytech.com.hk/upload/product/attachment/1024-240320g%20series-v21.pdf
Look on page 9. It shows the jumper and configuration options for the
LCD. It shows that the default interface is the Motorola interface. It says:
Quote: | M6800 Family Bus Interface (Default) |
This interfaces uses E, R/W, and RS (A0). But the driver that you have
posted uses the Intel-style interface, which uses RD, WR, CS, A0.
That explains why nothing works. The LCD is jumpered for the Motorola
interface, and you're using the Intel-interface driver.
So the solution is:
1. Change the jumper (or a solder-bridge across 2 pads) configuration
on the LCD to Intel mode (DisplayTech calls it "generic" interface).
or
2. Find another driver that works in Motorola mode.
or
3. Convert the existing driver to Motorola mode. |
|
|
modus83
Joined: 13 Apr 2010 Posts: 7
|
|
Posted: Tue May 25, 2010 4:15 pm |
|
|
PCM programmer wrote: | I assume this is the data sheet for your LCD.
http://www.displaytech.com.hk/upload/product/attachment/1024-240320g%20series-v21.pdf
Look on page 9. It shows the jumper and configuration options for the
LCD. It shows that the default interface is the Motorola interface. It says:
Quote: | M6800 Family Bus Interface (Default) |
This interfaces uses E, R/W, and RS (A0). But the driver that you have
posted uses the Intel-style interface, which uses RD, WR, CS, A0.
That explains why nothing works. The LCD is jumpered for the Motorola
interface, and you're using the Intel-interface driver.
So the solution is:
1. Change the jumper (or a solder-bridge across 2 pads) configuration
on the LCD to Intel mode (DisplayTech calls it "generic" interface).
or
2. Find another driver that works in Motorola mode.
or
3. Convert the existing driver to Motorola mode. |
Thank you so much for your answer!! Tomorrow morning I'm going to change
the CNF to Intel interface.
If I don´t know how to do that, surely I will try to convert my driver to the M6800 language.
I haven´t seen it before!! Hopefully it works!!
Regards |
|
|
modus83
Joined: 13 Apr 2010 Posts: 7
|
|
Posted: Wed May 26, 2010 5:51 am |
|
|
It doesn't works....
Maybe "Generic bus" is not 8080 interface....
I'm going to try convert the code into 6800 format...
Then:
#RD = E
#WR = R/#W
A0 = A0
#CS = #CS
#RST = #RST
is it correct?
So, this:
Code: |
output_low (GLCD_A0); //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);
|
Should be....
Code: |
output_low (GLCD_RW);
output_low (GLCD_A0);
output_low(GLCD_CS);
output_lcd((data));
output_high (GLCD_E);
delay_cycles( 2 );
output_low (GLCD_E);
delay_cycles( 2 );
output_high(GLCD_CS);
|
|
|
|
msakms
Joined: 20 Nov 2011 Posts: 7 Location: Doha/Qatar
|
|
Posted: Mon Dec 12, 2011 5:14 pm |
|
|
I've had a similar issue so, may be this will work for you. Try making a short between the Vdd "+ve supply" and the V0 "Pin 18" then release. See if that shows anything on your GLCD. I had a contrast adjustment issue although I followed the datasheet to the letter.
Good luck. |
|
|
|