Jump to content

HD44780 8-bit mode


Fede

Recommended Posts

Goodmorning all!

I don't know if it is useful to someone but this is the correct function that initialize the HD44780 in 8 bit mode:

(file: ugfx/drivers/tdisp/hd44780/tdisp_lld.c)


bool_t tdisp_lld_init(void) {
/* initialise hardware */
init_board();

/* The first part is the initialing code.
* In this part only the lower nibble of the
* byte is written directly to the display, thus
* without write_cmd, which sends both high and
* low nibble.
*/

/* Give the LCD a little time to wake up */
gfxSleepMilliseconds(15);

/* clear the RS-line to the display */
palClearPad(PORT_CTRL, PIN_RS);
#if BUS_4BITS
/* write three times 0x03 to display (4-bit mode only)
* with RS = low.
*/
writeToLCD(0x03); // 1x
gfxSleepMilliseconds(20);
writeToLCD(0x03); // 2x
writeToLCD(0x03); // 3x
/* Put display in 4-bit mode by
* write 0x02 to display.
*/
writeToLCD(0x02); // 4bit-modus
#else
/* 8-bit modus, 2 lines en 5x7 characters */
/* write three times 0x30 to display (8-bit mode only)
* with RS = low.
*/
writeToLCD(0x30); // 1x
gfxSleepMilliseconds(5);
writeToLCD(0x30); // 2x
writeToLCD(0x30); // 3x
#endif

/* From this point on, the LCD accepts
* bytes sent with highnibbel first and than
*the lownibble if working in 4-bit mode.
* In 8-bit mode bytes are written in 1 action.
*/


#if BUS_4BITS
/* 4-bit modus, 2 lines en 5x7 characters */
write_cmd(0x28);
/* set display on, cursor off and no blinking */
write_cmd(0x0C);
/* set cursor increase and direction */
write_cmd(0x06);
#else
/* 8-bit modus, 2 lines en 5x7 characters */
write_cmd(0x38);
/* set display on, cursor off and no blinking */
write_cmd(0x0C);
/* set cursor increase and direction */
write_cmd(0x06);
#endif

displaycontrol = TDISP_DISPLAY_ON;
cursorcontrol = TDISP_CURSOR_INC;
/* END OF INITIALISATION */

return TRUE;
}

bye,

Fede

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...