??? 07/28/04 13:01 Read: times |
#75029 - RE: LCD Help! Responding to: ???'s previous message |
hi,
first all, I hope you add some comments next time. Now it is about the program. As I already said: RS line must be changed before E: rising edge of E locks RS and R/W states; falling edge of E locks and processes data/command from bus. By the way, I assume that R/W signal of LCD is tied to GND to select write option, isn`t it? As well, after power-up, you should wait at least 15ms before initialization of LCD. Try next: // somewhere at beginning: #define LCD_RS P3_6 #define LCD_E P3_7 #define LCD_BUS P1 // ... // LCD initialization void LCD_INT(void) { // set strobe to default state // (after MCU reset/power-up, all pins are high !) LCD_E = 0; // setup interface LCD_RS = 0; LCD_E = 1; // select command register LCD_BUS = 0x38; // 8-bit bus, 2 lines, 5x7 dots LCD_E = 0; // strobe command LCDDelay40us(); // wait for at least 40us // Note: some vendors recommend to repeat // setup interface sequence at least 3 times // with 5ms pauses) // now I recommend to do total reset of LCD: //LCD_RS = 0; LCD_E = 1; // select command register LCD_BUS = 0x01; // clear display and move cursor and DRAM pointer to start position LCD_E = 0; // strobe command LCDDelay1700us(); // wait for at least 1.7ms // visual setup //LCD_RS = 0; LCD_E = 1; // select command register LCD_BUS = 0x0e; // display on, cursor on, flash off LCD_E = 0; // strobe command LCDDelay40us(); // wait for at least 40us //LCD_RS = 0; LCD_E = 1; // select command register LCD_BUS = 0x06; // cursor scroll direction to right LCD_E = 0; // strobe command LCDDelay40us(); // wait for at least 40us } // LCD data write void LCD_WR_DAT(void) { LCD_RS = 1; LCD_E = 1; // select data memory //LCD_BUS = 0xXX; // has already wrote in your case LCD_E = 0; // strobe data LCDDelay40us(); // wait for at least 40us }Some additional notes about delays. LCD interface requires: - delay between RS and E at least 140ns; - delay between bus and E at least 195ns; - E high state duration at least 450ns; - inactive state at least 10ns. All these timings are safely provided with standard 8051 (at OSC 24MHz the shortest instruction takes 500ns). If you have high speed part then insert these delays as well. Regards, Oleg |
Topic | Author | Date |
LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: LCD Help! | 01/01/70 00:00 | |
RE: Lookup table![]() | 01/01/70 00:00 | |
Use a switch statement! | 01/01/70 00:00 |