LCD Custom Character Code Templates
LCD Custom Character Code Templates
mikroC provides a library for communication with LCDs (with HD44780 compliant controllers) through
the 4-bit interface. An example of LCD connections is given on the schematic at the bottom of this page.
For creating a custom set of LCD characters use LCD Custom Character Tool.
Note: mikroElektronika's development system based initialization routines are included in Code
Templates.
Note: Only Lcd_Config and Lcd_Init routines use the RW pin (RW pin is configured as output and set to
zero). If the user needs this pin for other purposes, it can be reconfigured after Lcd_Config or Lcd_Init
call.
Library Routines
Lcd_Config
Lcd_Init
Lcd_Out
Lcd_Out_Cp
Lcd_Chr
Lcd_Chr_Cp
Lcd_Cmd
Lcd_Config
Prototype void Lcd_Config(unsigned short *port, unsigned short RS, unsigned short EN, unsigned
short WR, unsigned short D7, unsigned short D6, unsigned short D5, unsigned short D4);
Returns Nothing.
Description Initializes LCD at port with pin settings you specify: parameters RS, EN, WR, D7 .. D4 need to
be a combination of values 0–7 (e.g. 3,6,0,7,2,1,4).
Requires Nothing.
Lcd_Init
Returns Nothing.
Description Initializes LCD at port with default pin settings (see the connection scheme at the end of the
chapter):
D7 → port.7
D6 → port.6
D5 → port.5
D4 → port.4
E → port.3
RS → port.2
RW → port.0
Requires Nothing.
Example Lcd_Init(&PORTB);
Lcd_Out
Prototype void Lcd_Out(unsigned short row, unsigned short col, char *text);
Returns Nothing.
Description Prints text on LCD at specified row and column (parameters row and col). Both string
variables and literals can be passed as text.
Lcd_Out(1, 3, "Hello!");
Lcd_Out_Cp
Returns Nothing.
Description Prints text on LCD at current cursor position. Both string variables and literals can be passed
as text.
Lcd_Chr
Prototype void Lcd_Chr(unsigned short row, unsigned short col, char character);
Returns Nothing.
Description Prints character on LCD at specified row and column (parameters row and col). Both
variables and literals can be passed as character.
Lcd_Chr(2, 3, 'i');
Lcd_Chr_Cp
Returns Nothing.
Description Prints character on LCD at current cursor position. Both variables and literals can be passed
as character.
Lcd_Chr_Cp('e');
Lcd_Cmd
Returns Nothing.
Description Sends command to LCD. You can pass one of the predefined constants to the function. The
complete list of available commands is below.
Lcd_Cmd(Lcd_Clear);
Library Examples
Use Lcd_Init for default pin settings (see the first figure below).
void main() {
}//~!