LCDInfo.com

http://www.lcdinfo.com
It is currently Fri Nov 22, 2024 0:17

All times are UTC + 2 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Mon Feb 25, 2008 6:06 
Offline

Joined: Wed Feb 20, 2008 7:48
Posts: 2
Hello all,
I am working with Lpc 2106 controller and Hitachi Monochrome 4 bit
LCD,320x240 pixels with S1D13700 Lcd Controller.I have done initialize code..

But LCd Not initializing...


Please go through my code..

#include <LPC210X.H>
//#include<stdio.h>
//#include"font.h"

#define HIGH 1
#define LOW 0


#define SYSTEM_SET 0x40
#define POWER_SAVE 0x53
#define DISPLAY_OFF 0x58
#define DISPLAY_ON 0x59
#define SCROLL 0x44
#define CSRFORM 0x5D
#define OVERLAY 0x5B
#define CGRAM_ADR 0x5C
#define HDOT_SCR 0x5A
#define CSRW 0x46
#define CSRR 0x47
#define GRAYSCALE 0x60
#define MEMWRITE 0x42
#define MEMREAD 0x43

#define A0 (1<<28)
#define READ (1<<29)
#define WRITE (1<<19)
#define CS (1<<20)
#define WAIT (1<<21)
//#define RESET (1<<28)

//#define D0 (1<<10)

void command_write(int);
void parameter_write(int);



//unsigned char LcdBufFont[240][40];
//char screen_invert = 0xff;
//int wait;

__inline void output_data(int data)
{
IOSET = data<<6;
IOCLR = (~data<<6);
}

void output_bit(long pin,char data)
{
if(data)
IOSET = pin;
else
IOCLR = pin;
}


int main(void)
{
int i;
// 29-28 21-20 19,17 -10
IODIR = 0x303BFC00; // 0011 0000 0011 1011 1111 1100 0000 0000
output_bit(WRITE,LOW); // 3 0 3 B F C 0 0
output_bit(READ,LOW);
output_bit(CS,LOW);

/* Indirect Addressing Initialization Procedure*/

/*############# SYSTEM_SET ######################### */


command_write(SYSTEM_SET); /* C system_set Command */

for(i=0;i<3000;i++);

parameter_write(0x38); /*P1 INTERGAL cgroM 8 LINES PER CHAR,Dual panel Drive */

parameter_write(0x87); /* P2 Horizontal_character size 8 pixels*/

parameter_write(0x07); /* P3 Vertical Character size 8 pixels */

//C/R

parameter_write(0x4F); /* P4 No of Bytes per Line 40*2-1 =79*/

// TC/R


parameter_write(0x53); /* P5 Total Characres Per ROW 79+4 */

parameter_write(0xEF); /* P6 L/F 240 display Lines* 240-1 */

parameter_write(0xF0); /* P7 virtual screen Size 240 */

parameter_write(0x00); /* P8 for Indirect Addressing Power save mode to be disable */


/* ########### SCROLL ###################### */

// 320x240 pixels ,Double panel Drive
//First Layer Text : 320/8 = 40 characters per Line
//240/8 = 30 Characters per Line
// 40x30 =1200 bytes

//Second Layer Graphics

// 320/8 = 40 characters per Line
//240/1 =240 Lines

// 40x240 = 9600 bytes.. 2580 in HEX 2580+1000 = 3580 hex SAD3

command_write(SCROLL);

parameter_write(0x00); // p1 // First Screen Block Start Address

parameter_write(0x00); //p2 // set to 0000 h

parameter_write(0x28); // p3




parameter_write(0x00); // p4 // Second Screen Block Start Address

parameter_write(0x10); //p5 //set to 1000 h


parameter_write(0x28); //p6



parameter_write(0x00); //p7 // 3rd Screen Block Start Address


parameter_write(0x4B); // p8 // set to 004Bh =1200 Bytes



parameter_write(0x80); //p9 //4th Screen Block Start Address


parameter_write(0x35); // p10 //Set to 3580h


/*############## HDOT SCR ################# */

command_write(HDOT_SCR);

parameter_write(0x00);


/* ############ OVER LAY ################## */

command_write(OVERLAY);
parameter_write(0x01); /* EX-OR Layered Screen Composition Method */

// First Screen Block in Text Mode
// Third Screen Block in Text Mode

/* ########### DISPLAY off ############## */

command_write(DISPLAY_OFF); /*Display off*/

parameter_write(0x56); /* Flash Cursor at 2 HZ */

parameter_write(0x08); /* First Screen Block ON */

parameter_write(0x20); /* Second Screen Block ON */

parameter_write(0x80); /* Third Screen Block ON */


/* Fill the First Layer Memory with 20h */

/* ########## MWRITE ################ */

command_write(CSRW); /* set the cursor */

command_write(MEMWRITE); // MWrite

parameter_write(0x00);

parameter_write(0x00); // Set to 0000 for 1st screen Block..


parameter_write(0x20);

command_write(CSRW); /* set the cursor */

command_write(MEMWRITE); // MWrite

parameter_write(0x00);
/* Second Screen Layer */
parameter_write(0x10);

parameter_write(0x00);

command_write(CSRW); /* Set the Cursor to start of First screen block */

parameter_write(0x00);


// parameter_write()

// CSR FORM Cursor size

command_write(CSRFORM);

parameter_write(0x04);

parameter_write(0x86);


// DISPLAY ON


command_write(DISPLAY_ON);


//CSR DIR

command_write(0x42);

parameter_write(0x20); // " "

parameter_write(0x45); // E

parameter_write(0x50); // P

parameter_write(0x53); // S

parameter_write(0x4f); // O

parameter_write(0x4e); // N



}

void command_write(int C)
{
output_bit(A0,HIGH); // Command_write
output_bit(CS,LOW); // A0 --> HIGH
output_bit(WRITE,LOW); // _
// WR --> LOW
output_bit(READ,HIGH); // _
output_data(C); // RD --> HIGH
// output_bit(WAIT,LOW);
output_bit(WRITE,HIGH);
// output_bit(WAIT,HIGH);
}

void parameter_write(int D)
{
output_bit(A0,LOW);
output_bit(CS,LOW);
output_bit(WRITE,LOW);
output_bit(READ,HIGH);
output_data(D);
// output_bit(WAIT,LOW);
output_bit(WRITE,HIGH);
// output_bit(WAIT,HIGH);
}


if anywhere i have done mistake,,Please reply me...and suggust me what is the real problem..


Regards,
G.srinivasan.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 9 guests


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

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group