dashkil
Member level 2
i am interfacing a lcd(which has a ST7066U lcd driver), with AT-89S51 and OSC-20mhz, my code is working in proteus 7.7, but not working in hardware, i am posting the code below: PLZ help me
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 #define count 1700 // for 1 ms(approximate) #include <REGX51.H> sbit RS=P1^0; sbit RW=P1^1; sbit EN=P1^2; //***********************************// void delay(unsigned int ms); // for Lcd delay void enable(); // for strobe control void command(unsigned char cmd_code); // for instruction void Lcd_string(unsigned char *text); // for writting a string void Lcd_int(); // for Lcd initialization //***********************************// void main() { delay(50); while(1) { Lcd_int(); Lcd_string("ALMIGHTY *****"); delay(200); } } //***********************************// void delay(unsigned int ms) { unsigned char n; unsigned int i; for(n=0;n<ms;n++) { for(i=0;i<count;i++) ; } } //************************************// void enable() { EN=1; delay(1); EN=0; delay(2); } //************************************// void command(unsigned char cmd_code) { P2=cmd_code; enable(); } //************************************// void Lcd_int() { RS=0; // for instruction data RW=0; // for write operation EN=0; // enable is low command(0x30); // mode 8 bit, 1 line display,font 5x8 command(0x30); command(0x0F); // entire display on,cursor on,blinking on command(0x02); // return cursor to origin command(0x01); // clear display command(0x06); // entry mode is set } //************************************// void Lcd_string(unsigned char *text) { RS=1; RW=0; while(*text!='\0') { P2=*text++; // for outputing a single byte at a time enable(); } } //************************************//