/* * Initialize the LCD controller. * * The initialization sequence has a mandatory timing so the * controller can safely recognize the type of interface desired. * This is the only area where timed waits are really needed as * the busy flag cannot be probed initially. */ void hd44780_init(void) { DDRB = 0xFF; // Data port out DDRD = 0xF2; // (comment was obsolete) _delay_ms(15); /* 40 ms needed for Vcc = 2.7 V */ hd44780_outcmd(HD44780_FNSET(1, 0, 0)); _delay_ms(4.1); hd44780_outcmd(HD44780_FNSET(1, 0, 0)); _delay_ms(0.1); hd44780_outcmd(HD44780_FNSET(1, 0, 0)); hd44780_outcmd(HD44780_FNSET(1, 1, 0)); hd44780_wait_ready(); hd44780_outcmd(HD44780_FNSET(1, 1, 0)); hd44780_wait_ready(); hd44780_outcmd(HD44780_DISPCTL(0, 0, 0)); hd44780_wait_ready(); }
/* * Initialize the LCD controller. * * The initialization sequence has a mandatory timing so the * controller can safely recognize the type of interface desired. * This is the only area where timed waits are really needed as * the busy flag cannot be probed initially. */ void hd44780_init(void) { SET(DDR, HD44780_RS); SET(DDR, HD44780_RW); SET(DDR, HD44780_E); ASSIGN(DDR, HD44780_D8, 0xFF); _delay_ms(150); /* 40 ms needed for Vcc = 2.7 V */ hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0); _delay_ms(41); hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0); _delay_ms(1); hd44780_outbyte(HD44780_FNSET(1, 0, 0), 0); _delay_us(370); hd44780_outcmd(HD44780_FNSET(1, 1, 0)); hd44780_wait_ready(false); hd44780_outcmd(HD44780_DISPCTL(0, 0, 0)); hd44780_wait_ready(false); }