BiOzZ wrote:thank you but im a bit confused, LCD_Write does not seam like a normal command do you know what data is being sent? and in what order?
Let's take a step back: The LCD in question has a 20-pin header:
1 Vdd
2 Vss
3 V0
4 D0
5 D1
6 D2
7 D3
8 D4
9 D5
10 D6
11 D7
12 CS2
13 CS1
14 RST
15 R/W
16 D/I
17 E
18 Vee
19 Anode
20 Cathode
Do you have these connections made?
In order to write to or read from the LCD, you need to look at the datasheet and ensure you drive the pins per the sheet. I wrote myself a whole "driver", higher and lower-level functions for doing just that. For instance, writing a byte to the LCD involves twiddling the data and control lines to the LCD in a specific way. My write command looks like this:
Code: Select allvoid LCD_Write( unsigned char ucCommandData, unsigned char ucData, unsigned char ucChipSelectMask )
{
unsigned char
bStatus;
M8C_DisableGInt;
EnableWrite();
if( ucCommandData == LCD_COMMAND )
LCD_CTLPRTSHADOW &= ~LCD_DIMASK; //drive DI low for command
else
LCD_CTLPRTSHADOW |= LCD_DIMASK; //drive DI high for data
LCD_CTLPORT = LCD_CTLPRTSHADOW;
if( ucChipSelectMask == LCD_CS1MASK )
{
LCD_CTLPRTSHADOW &= ~LCD_CS1MASK; //drive selected bank CS
LCD_CTLPRTSHADOW |= LCD_CS2MASK; //ensure other one is deselected
}//if
else
{
LCD_CTLPRTSHADOW |= LCD_CS1MASK;
LCD_CTLPRTSHADOW &= ~LCD_CS2MASK;
}//else
LCD_CTLPORT = LCD_CTLPRTSHADOW;
asm( "nop" );
asm( "nop" );
LCD_DATAPORT = ucData; //put data there
LCD_CTLPRTSHADOW |= LCD_EMASK; //drive E high
LCD_CTLPORT = LCD_CTLPRTSHADOW;
asm( "nop" );
asm( "nop" );
asm( "nop" );
LCD_CTLPRTSHADOW &= ~LCD_EMASK; //drive E low
LCD_CTLPORT = LCD_CTLPRTSHADOW;
asm( "nop" );
asm( "nop" );
//
LCD_CTLPRTSHADOW |= LCD_CS1MASK;
LCD_CTLPRTSHADOW |= LCD_CS2MASK;
LCD_CTLPORT = LCD_CTLPRTSHADOW;
asm( "nop" );
asm( "nop" );
asm( "nop" );
if( ucCommandData == LCD_COMMAND )
{
do
{
M8C_ClearWDT;
if( ucChipSelectMask == LCD_CS1MASK )
bStatus = LCD_ReadStatus( LCD_CS1MASK );
else
bStatus = LCD_ReadStatus( LCD_CS2MASK );
bStatus &= LCDSTATUS_BUSY; //mask out all but busy bit
}while( bStatus );
}//if
M8C_EnableGInt;
}//LCD_Write
So LCD_Write(), the command I wrote, allows me to write command or data to the LCD. Similarly, I can read the status back after commands are sent to wait for the module to finish (looking at the busy flag...) My LCD_Write() command takes three parameters. The first is an indicator of whether the byte being written is a command or data. This determines how the logic drives the D/I pin and whether the busy flag is checked. The second is the byte to write and the third (which I inadvertently left out of the DrawLine1() example I posted earlier where I write 0xFF to the LCD...) is which of the two modules is being written to.
So with regard to what to send, look at the datasheet:
http://www.sparkfun.com/datasheets/LCD/GDM12864H.pdf
and go to page 10. There's a table showing everything you can do with the LCD. It illustrates the state of each pin (RS is "D/I" by the way...) and which data bits do what.
The tougher thing to understand is how the display is layed out and how a given pixel on the screen corresponds to a page, a column and the byte written there
and the fact that there are essentially two distinct modules to deal with.
i have no experience with graphic displays and every other display i have worked with i send mostly raw data to it like if each row is a pin form 0-7 i normally work like this
01000111
10110111
01101001
01001111
and than i make librarys from that and work from there. right now i want to go simple and play with the arduino
can you tell me what i need to send to what pin (besides the deta pins)
than how to use the data pins?
im sorry but this is my first graphic display
May I ask if you've had much microcontroller and/or interfacing experience? The issue of reading the datasheet and determining what data bits do what when writing to or reading from an external device isn't unique to graphical LCDs. Even character LCDs with parallel interfaces use the same basic signaling (though they usually have only one controller.)
Aside from power for the LCD (Vdd and Vss) contrast (V0 and Vee) and the backlight (anode and cathode), from the micro, you need:
4..11 D0..D7 input/output
12 CS2 output
13 CS1 output
14 RST output
15 R/W output
16 D/I output
17 E output
The datasheet, on pages 7 and 8, show the idle and active levels for each signal and the timing requirements. Using this you should be able to write some low-level stuff to send command and data bytes to the LCD and read status and even data back. For many microcontrollers this means bit banging. Some micros might have a bus interface that allows a write to an address which automatically generates bus control signals (e.g. E) but most micros will require you to do this manually. My LCD_Write above shows this.
Once you have that, then you can use page 10 to write some slightly higher-level stuff to set the display memory pointer (X,Y), set the start line and turn the display on and off.
Once you've initialized the LCD, set the X,Y addresses to 0,0 and write 0xFF. What do you see?