|
发表于 2010-9-27 02:46:34
|
显示全部楼层
"但网上的文档很少详细说明4线的初始化情况"
you should try the datasheet.
but here is my initialization sequence for HD44780-compatible devices.
==========code=============
//IO_CLR(LCD_CTRL_PORT, LCD_EN);
delay_ms(15); // wait 15mSec after power applied,
LCD_SET(D4 | D5); LCD_CLR(D6 | D7);
LCD_STROBE(0);
delay_ms(5); //delay 5ms
LCD_STROBE(0);
delay_us(200); //delay 200us
LCD_STROBE(0);
delay_us(200); //delay 200us
IO_CLR(LCD_CTRL_PORT, LCD_RS);
#if LCD_8BIT == 0 //in 4-bit mode
LCD_SET(D5); LCD_CLR(D4 | D6 | D7);
LCD_STROBE(0);
lcd_write(LCD_FOUR_BIT & LCD_LINES_5X7, 0); // function control, 4bit, 2line, 5x7 dots
#else
// IO_CLR(LCD_CTRL_PORT, LCD_RS);
lcd_write(LCD_EIGHT_BIT & LCD_LINES_5X7, 0); // function control, 8bit, 2line, 5x7 dots
#endif
lcd_write(LCD_DISPLAY_ON & LCD_CURSOR_OFF & LCD_BLINK_OFF, 0); //display on, cursor off, blink off
lcd_clear(); // Clear screen
lcd_write(LCD_SHIFT_DISPLAY_OFF & LCD_SHIFT_CURSOR_RIGHT, 0); // Set entry Mode, increment, don't shift.
==========end============
so you have to send 0x3X (the lower 4 bits are ignored) 3x at various timing intervals.
then based on which mode you are in, you may have to send 0x2X (X is anything) to enter the four bit mode.
the datasheet has it pretty clearly stated:
点击此处下载 ourdev_585839EI3MS6.pdf(文件大小:322K) (原文件名:HD44780.pdf) |
|