??? 04/19/04 10:22 Read: times |
#68749 - LCD Cursor Problem |
Hello every body,
I am using a 8*2 line LAMPEX LCD display and I am able to display all the things but there are very small problems with displaying on the LCD. I have made a surch on 8052 and found 163 pages for LCD Cursor but my problem was not discussed. Since I have a 8*2 line LCD I have one line whose DDRAM address is 0x80 and seconds is 0xc0. Now my cursor can be seen from second digit to the seventh digit then on the eight digit the cursor goes blank but I can write charactors on that location then the cursor again becomes visible from ninth location till end. And I am not able to write on the 16th location. Here is the LCD display code I am using Please guide me. #include<bullet.h> /* Content of bullet.h //keyboard display //sbit A0 = 0xe0; sbit LCDBAKLGHT = P2^6; sbit CLK373=P3^1; sbit LCDENABLE = P1^6; // enable sbit LCDREGISTER = P1^5; // rs #define LCDPORT P0 #define INSTNO 4 void initLcd() ; //Initialize LCD display void clear_lcd(void); void writeInstruct(unsigned char inst) ; void WriteInitInstr(void) ; void DisplayScan(void) ; //scan displays void dely(); // soft delay void display_char(unsigned char *disdta); unsigned char dispLcd(char *ptr); // display string in LCD extern unsigned char disp_pos; */ #include <intrins.h> void dely(); void lcdWait(); void writeInstruct(unsigned char inst); void WriteInitInstr(void); unsigned char dis_buf[16],disp_pos; code unsigned char inst_table[4]= { //Curser disp shift 0x14,//0001--0100 // s/c=0 cursor movement // r/l=1 move right //disp ON/OFF 0x0e,//00001--111 // D=1 entire display on // C=1 cursor on // B=1 cursor blink on //Entry Mode 0x06,//000001--10 // I/D=1 increment by one // S=0 0x01 //clear display };//2,0x28,8,1,6,0x0c,1,0x80}; /* INITIALISE LCD */ void initLcd() { unsigned char i; WriteInitInstr(); //write initialization instruction i = 0x35; //Delay do { dely(); i--; } while(i) ; // delay of 27.401ms with a crystal of 12 MHz WriteInitInstr(); // write initialization istruction. dely() ; // delay 500uS WriteInitInstr(); // write initialization istruction. dely() ; // delay 500uS WriteInitInstr(); // write initialization istruction. for(i=0;i<INSTNO;i++) // write 5 instructions from the array { dely() ; writeInstruct(inst_table[i]) ; } } /* Write Initialisation Instruction to LCD */ void WriteInitInstr(void) { LCDREGISTER=0; LCDENABLE=1; LCDPORT =0x38;// Initialization instruction for LCD /* Function set 8 bit interface 2 line display 5*7 dots */ SELECTLCD; LCDENABLE=0; } /* Send a byte to LCD Data or Instruction */ void writeByteToLcd(unsigned char LcdData,unsigned char RegType) { lcdWait() ; LCDREGISTER=RegType; LCDENABLE=1 ; SELECTLCD; LCDPORT=LcdData; SELECTLCD; LCDENABLE=0; } /* Display one charactor on the LCD */ void display_char(unsigned char* disdta) { dis_buf[disp_pos]=*disdta; if(disp_pos<15)disp_pos++; else disp_pos=0; } /* Write Instruction to LCD */ void writeInstruct(unsigned char instr) { writeByteToLcd(instr,0); } /* This function gives a delay of 0.515ms with the crystal of 12MHz */ void dely() { unsigned char i = 0xff ; while ( i ) i-- ; } void lcdWait() //HERE "5 NOPS" ARE GIVEN //AS WE DO NOT HAVE A PORT FREE FOR LCD_W_R { _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } /* Clear the display buffer from controller RAM and also send the clear LCD command */ void clear_lcd(void) { // clear display unsigned char i; for(i=0;i<16;i++) { dis_buf[i]=' '; // fill with space } writeInstruct(0x01);//Clear LCD i=0x35; do { dely(); i--; }while(i); //lcdWait(); } /* This routine puts the display buffer from the micro controller RAM on the LCD */ void DisplayScan(void) { static unsigned char DisplayPosition; for(DisplayPosition=0;DisplayPosition<disp_pos;DisplayPosition++) { if(!DisplayPosition) { writeInstruct(0x80); // initialize DDRAM address dely(); } else if(DisplayPosition==8) { writeInstruct(0xC0); // initialize DDRAM address dely(); } writeByteToLcd(dis_buf[DisplayPosition],1); dely(); } } /* Display a string on the LCD */ unsigned char dispLcd(char *ptr) { unsigned char i; i=0; while ( *ptr ) { // load the string to display buffer dis_buf[i]=(*ptr++) ; i++ ; } if(i>=15)return(0); else return(i); } Thanks in advance Sachin |
Topic | Author | Date |
LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem | 01/01/70 00:00 | |
RE: LCD Cursor Problem![]() | 01/01/70 00:00 |