hi, my self yogesh working on graphical display on which there is sanyo LC 7981 controller is present. this display is inter face with C8051F020. after putting a lot of effort i cannot able to produce character on the screen. for testing purpose i am using internal CG set. only i am getting the black box in the middle section of lcd. i am not used any pull up register at the port. i am also giving my code below. please suggest me how to overcome this problem. thanks
#pragma CODE //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- #include <stdio.h> #include "c8051f020.h" // SFR declarations #include "config.h" #include "lcd240x64.h" // definitions for the LCD controller // MAIN Routine //----------------------------------------------------------------------------- void main (void) { config(); // setup all the SFR initialization lcd_init(); // initialize LCD display lcd_cmd_1(0x0A,0x03); delay (90000); lcd_cmd_1(0x0B,0xFF); delay (90000); lcd_cmd_1(0x0C,0x42); delay (90000); }
#pragma CODE #include "c8051f020.h" // SFR declarations #include "lcd240x64.h" //#include "fonts.h" #include <intrins.h> /* ** Low level LCD Controller Interface Support Routines ** The LCD Controller interfaces to the microcontroller ** using the connections as shown below. ** ** P5^0 ** to +- Eight bit Data Bus to/from the LCD controller ** P5^7 / ** P3^0 LCD Controller Chip Select (CS) signal------------------------(CE) ** P3^1 LCD Controller Ctl/Data Select (RS) signal--------------------(C/D) ** P3^2 LCD Controller Write (R/W_Bar) signal-------------------------(WR/) ** P3^3 LCD Controller Read E signal----------------------------------(RD/) ** P3^4 LCD Controller Reset (RST/) signal----------------------------(RST/) */ /* ** routine to initialize the operation of the LCD display subsystem */ void lcd_init(void) { int i; /* initialize the port control lines to the LCD module */ LCD_CS = 0; /* set chip select high off output */ LCD_RS = 0; /* set the C/D line low as output */ LCD_RW = 1; /* set R/W line high as output */ LCD_E = 0; /* set RD line high as output */ /* reset the LCD controller chip */ LCD_RST = 0; /* set the reset line low */ for(i=0; i<10000; i++); /* delay for the reset time */ LCD_RST = 1; /* release reset to back high */ /* program the controller mode of operation to graphics only mode */ lcd_cmd_1(0x00,0x30); /* enable internal CG Mode */ delay (90000); lcd_cmd_1(0x01,0x85); /* set character pitch */ delay (90000); lcd_cmd_1(0x02,0x1E); /* set number of bytes in horz raster1E */ delay (90000); lcd_cmd_1(0x03,0x40); /* duty cyclec or no. of time division */ delay (90000); lcd_cmd_1(0x04,0x06); /* set thecursor position*/ delay (90000); lcd_cmd_1(0x08,0x00); /* set graphics start at zero */ delay (90000); lcd_cmd_1(0x09,0x00); /* set graphics start at zero */ delay (90000); } /* ** low level routine to send a byte value out port 2 bus to the LCD ** controller data register. entry argument is the data to output. */ void lcd_out_dat(unsigned char dat) { P74OUT = 0x0C; /* make the port in push pull configuration*/ LCD_CS = 0; /* enable chip select */ LCD_RS = 0; /* set the RS line high to data */ LCD_RW = 0; /* make sure the RD/ line is high */ delay (90000); delay (10); // Generate The Delay Of 140 ns. LCD_E = 1; // make E low for write (negative edge weiting) P5 = dat; /* output the data to bus */ delay (90000); delay (200); // Generate The Delay Of 450 ns minimum . LCD_E = 0; delay (90000); _nop_(); _nop_(); LCD_CS = 1; /* force the CS back high */ delay (90000); LCD_RW = 1; /* set the WR/ line back high */ } /* ** low level routine to send a byte value out port 2 bus to the LCD ** controller control register. entry argument is the data to output. */ void lcd_out_ctl(unsigned char dat) { P74OUT = 0x0C; /* make the port in push pull configuration*/ LCD_CS = 0; /* enable chip select */ LCD_RS = 1; /* set the RS line high to cmd */ delay (90000); LCD_RW = 0; /* make sure the RD/ line is high */ delay (90000); delay (20); // Generate The Delay Of 140 ns. LCD_E = 1; // make E low for write (negative edge weiting) P5 = dat; /* output the data to bus */ delay (90000); delay (200); // Generate The Delay Of 450 ns minimum . LCD_E = 0; delay (90000); _nop_(); _nop_(); delay (90000); LCD_RW = 1; /* set the WR/ line back high */ delay (90000); LCD_CS = 1; /* force the CE back high */ } /* ** low level routine to read a byte value from the LCD controller status ** register in via the data bus. the entry argument is the interrupt thread mode. */ unsigned char lcd_in_sta(void) { unsigned char dat; P74OUT = 0x00; // make the port configuretion in open drain delay (90000); LCD_CS = 0; /* enable chip select */ delay (90000); LCD_RS = 1; /* set the CD line high to cmd */ delay (90000); LCD_RW = 1; /* make sure the RD/ line is high */ delay(4); // Generate The Delay Of 140 ns. LCD_E = 1; // make E low for write (negative edge weiting) delay (90000); P5=0xFF; // P5 in input mode. delay(5); // delay time is 225ns. delay (90000); dat=P5; /* output the data to bus */ delay (100); // Generate The Delay Of 450 ns minimum . delay (90000); dat=P5; // LCD_E = 0; _nop_(); _nop_(); LCD_RW = 1; /* set the WR/ line back high */ delay (90000); LCD_CS = 1; /* force the CE back high */ return(dat); } /* ** low level routine to poll the LCD till the status bits STA0 and STA1 both ** report back as 1's to indicate that the chip is ready to take a command. */ void lcd_busy_wait(void) { unsigned char dat; do { delay (90000); delay (90000); dat=lcd_in_sta(); } while((dat & 0x80) == 0x80); } /* ** low level routine to send a one byte command to the LCD controller. ** the two entry parameters are the command code and the one byte parameter. */ void lcd_cmd_1(unsigned char cmd,unsigned char parm) { delay (90000); lcd_busy_wait(); /* wait for status on command */ lcd_out_ctl(cmd); /* send out the command itself */ lcd_out_dat(parm); /* send out the byte of the data */ lcd_busy_wait(); } void delay (unsigned int ns ) { unsigned int i; for(i=0; i<ns; i++); // _nop_(); }