Hello,
I have written a code for Graphical Serial LCD for displaying the Images on the Graphical LCD The LCD is TIANAMA 128x64 with Hitachi Controller.
With help of this code i am able to show any graphics on the lcd, but i am not able to write any text in any line, It shows only raster image on the Screen.
Please guide for further to write 4 lines on the lcd.
#include <Philips\P89V66x.h> #include <stdio.h> #include <intrins.h> #define SCK_bit 0 #define DIN_bit 2 #define SCK_set P4 |= (1<<SCK_bit) #define DIN_set P4 |= (1<<DIN_bit) #define SCK_clear P4 &= ~(1<<SCK_bit) #define DIN_clear P4 &= ~(1<<DIN_bit) sbit _CS = P2^3; sbit _RST = P2^2; sbit A0 = P2^1; /* These are not working because P4 is located at 0xA1, not bit addressable with sbit extension * sbit SCK = P4^0; * sbit DIN = P4^2; */ unsigned char ContrastLevel; // for contrast setting level //----------------------------------- // display data (128x64) //----------------------------------- unsigned char ContrastLevel; // for contrast setting level //----------------------------------- // dispaly data (128x64) //----------------------------------- unsigned char code Logo[]= { ... ... }; //----------------------------------- // Delay Routine //----------------------------------- void delayms(unsigned int m) // 12MHz Xtal, close to ms value { unsigned int j; unsigned int i; for(i=0; i<m; i++) for(j=0; j<109; j++) _nop_(); } //----------------------------------- // IO Routine //----------------------------------- void lcd_cmd(unsigned char Command) //send command { SCK_set; A0 = 0; _CS = 0; if (Command & 0x80) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x40) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x20) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x10) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x08) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x04) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x02) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (Command & 0x01) DIN_set; else DIN_clear; SCK_clear; SCK_set; _CS = 1; } void lcd_data(unsigned char DData) //send data { SCK_set; A0 = 1; _CS = 0; if (DData & 0x80) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x40) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x20) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x10) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x08) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x04) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x02) DIN_set; else DIN_clear; SCK_clear; SCK_set; if (DData & 0x01) DIN_set; else DIN_clear; SCK_clear; SCK_set; _CS = 1; } //----------------------------------- // Write a Screen //----------------------------------- void WriteScreen(unsigned char *DisplayData) // DisplayData should be 164x64/8 = 1312byte { unsigned char TempData; unsigned char i, j; for(i=0;i<8;i++) { lcd_cmd(0xb0 | i); // select page 0~7 lcd_cmd(0x10); // start form column 4 lcd_cmd(0x00); // (2byte command) for(j=0;j<128;j++) { TempData=(*(DisplayData+(i*128)+j)); lcd_data(TempData); } } } void lcd_string(unsigned char row_add, char *str_base) { unsigned char i=0; lcd_cmd(row_add); while(str_base[i] != '\0') { lcd_data(str_base[i]); i++; } } //----------------------------------- // Main Program //----------------------------------- void main() { EA = 0; // disable interrupts _CS = 1; _RST = 1; A0 = 1; SCK_set; DIN_set; initLCDM(); LCD_Lighter(); //WriteScreen(Logo); lcd_string(0x80,"Hello World"); while(1); }
Why a new thread, when you already have an existing thread?
http://www.keil.com/forum/19751/
In that particular thread, the problem was toggling the bits as per the requirements.
I have studies the datasheet of the LCD module and controller, As per the instructions i have written the code at the end.
but it shows only raster image on the lcd.
whole display is blank and the raster is available at beginning of the Graphical LCD.
DO NOT make loop delay routines in 'C'
Erik
Come on Erik! Quit beating this dead horse. A simple C loop for some delay is quite sufficient. Of course if the Op is trying to hold a millisecond he is using the wrong tools but if the Op just wants some delay without any degree of accuracy then the C loop is prefect valid. If fact, about every example program in the Keil examples uses the same type of rough delay.
The Op did not even call the delay function is this code example so I am quite sure the delay is quite accurate enough :).
Bradford
But the compiler could optimise it to no delay at all!
"about every example program in the Keil examples uses the same type of rough delay"
They really should know better!!
Maybe the use of the _nop_() intrinsic prevents that...?
Discussing for delays is out of focus for this case, since staster image is presented to GLCD.
It seems that this method is successfull to send commands and data to GLCD for bitmap graphics.
Is there other type of commands to send text and this rendered by the device ?
The type/model/manufacturer of the GLCD never mentioned. LCD is TIANAMA 128x64 with Hitachi Controller ?
A link to GLCD datasheet is never posted.
A similar (successfull) case which is presented at:
www.8052.com/.../GraphLCD.phtml
There is described fonts, glyphs, ASCII, rendering etc.
BUT this is not a copy paste case.
Please find the link for the datasheet.
www.tianma-usa.com/.../44s1d15000tm.pdf
It is also done with above 8052 code, but it is not working for the same.
all the methods currently not working, I have also reffered all the datasheets but it is not working.