??? 11/10/06 05:27 Read: times |
#127685 - Read data in the display data RAM of graphic LCD |
Hi,
To read the display data RAM in the LCD and store the read value in an array, value[]. Here, I’m using the 6x8 font for displaying the characters. Using lcd_read_data, the hex values equivalent to the character are not getting read completely. For example, consider a single character “K”à equivalent hex values are 0x7f, 0x08, 0x14, 0x22, 0x41 void lcd_write_data(char value[6]) ; void LcdWaitBusy(void); unsigned char *row ="K"; unsigned char read_value[6]; void main(void) { //SFR initialization… //global interrupt enable SFRPAGE = CONFIG_PAGE; lcd_init(); lcd_gotoxy(0,2); lcd(row); lcd_gotoxy(0,2); for(i=0;i<6;i++) { read_value[i]=lcd_read_data(); //read data in the DDRAM } while(1) { lcd_gotoxy(0,4); lcd_write_data(read_value);//write the data read from DDRAM } } unsigned char lcd_read_data() { unsigned char dat; LCD_DI=1; //data mode LCD_RW=1; //read mode P7=0xff; //all pins of port d is set for input mode if(x_position > 63) { LCD_CS2=1; sleep(5); LCD_E=1; //strobe sleep(5); LCD_E=0; sleep(5); LCD_E=1; sleep(5); dat = LCD_DATA; LCD_E=0; sleep(5); LCD_CS2=0; } else { LCD_CS1=1; sleep(2); LCD_E=1; sleep(2); LCD_E=0; sleep(2); LCD_E=1; sleep(2); // LcdWaitBusy(); dat = LCD_DATA; LCD_E=0; sleep(2); LCD_CS1=0; } LCD_RW=0; P7=0x00; //all pins of port d is set for output mode return dat; } using the above lcd_read_data() subroutine, the hex values are read correctly. But, among the five hex values only the 1st,3rd and 5th hex values are read. 2nd and 4th hex values are getting missed. i.e., in the example character “K”, only 0x7f, 0x14, 0x41 are getting read and stored in the value[]. Using the below LcdWaitBusy() routine, the read value remains 0xFF. void LcdWaitBusy(void) { LCD_DI = 0; // Instruction mode LCD_RW = 1; // Read mode LCD_DATA = 0xFF; do { sleep(2); LCD_E=1; sleep(2); LCD_E=0; } while(LCD_DATA & DISPLAY_STATUS_BUSY); return; } I couldn't find the mistake in checking the lcd_read_data and read status subroutines... Help me to solve the problem. Regards, veena. |