Lcd Library

mikroPascal PRO for ARM provides a library for communication with Lcds (with HD44780 compliant controllers) through the 4-bit interface.

For creating a set of custom Lcd characters use Lcd Custom Character Tool.

Library Dependency Tree

Lcd Library Dependency Tree

External dependencies of Lcd Library

Stellaris

The following variables must be defined in all projects using Lcd Library : Description : Example :
var LCD_RS : sbit; sfr; external; Register Select line. var LCD_RS : sbit at GPIO_PORTA_DATA.B2;
var LCD_EN : sbit; sfr; external; Enable line. var LCD_EN : sbit at GPIO_PORTA_DATA.B3;
var LCD_D7 : sbit; sfr; external; Data 7 line. var LCD_D7 : sbit at GPIO_PORTA_DATA.B4;
var LCD_D6 : sbit; sfr; external; Data 6 line. var LCD_D6 : sbit at GPIO_PORTA_DATA.B5;
var LCD_D5 : sbit; sfr; external; Data 5 line. var LCD_D5 : sbit at GPIO_PORTA_DATA.B6;
var LCD_D4 : sbit; sfr; external; Data 4 line. var LCD_D4 : sbit at GPIO_PORTA_DATA.B7;
var LCD_RS_Direction : sbit; sfr; external; Register Select direction pin. var LCD_RS_Direction : sbit at GPIO_PORTA_DIR.B2;
var LCD_EN_Direction : sbit; sfr; external; Enable direction pin. var LCD_EN_Direction : sbit at GPIO_PORTA_DIR.B3;
var LCD_D7_Direction : sbit; sfr; external; Data 7 direction pin. var LCD_D7_Direction : sbit at GPIO_PORTA_DIR.B4;
var LCD_D6_Direction : sbit; sfr; external; Data 6 direction pin. var LCD_D6_Direction : sbit at GPIO_PORTA_DIR.B5;
var LCD_D5_Direction : sbit; sfr; external; Data 5 direction pin. var LCD_D5_Direction : sbit at GPIO_PORTA_DIR.B6;
var LCD_D4_Direction : sbit; sfr; external; Data 4 direction pin. var LCD_D4_Direction : sbit at GPIO_PORTA_DIR.B7;

MSP432

The following variables must be defined in all projects using Lcd Library : Description : Example :
var LCD_RS : sbit; sfr; external; Register Select line. var LCD_RS : sbit at DIO_P6OUT.B2;
var LCD_EN : sbit; sfr; external; Enable line. var LCD_EN : sbit at DIO_P6OUT.B3;
var LCD_D7 : sbit; sfr; external; Data 7 line. var LCD_D7 : sbit at DIO_P6OUT.B4;
var LCD_D6 : sbit; sfr; external; Data 6 line. var LCD_D6 : sbit at DIO_P6OUT.B5;
var LCD_D5 : sbit; sfr; external; Data 5 line. var LCD_D5 : sbit at DIO_P6OUT.B6;
var LCD_D4 : sbit; sfr; external; Data 4 line. var LCD_D4 : sbit at DIO_P6OUT.B7;
var LCD_RS_Direction : sbit; sfr; external; Register Select direction pin. var LCD_RS_Direction : sbit at DIO_P6DIR.B2;
var LCD_EN_Direction : sbit; sfr; external; Enable direction pin. var LCD_EN_Direction : sbit at DIO_P6DIR.B3;
var LCD_D7_Direction : sbit; sfr; external; Data 7 direction pin. var LCD_D7_Direction : sbit at DIO_P6DIR.B4;
var LCD_D6_Direction : sbit; sfr; external; Data 6 direction pin. var LCD_D6_Direction : sbit at DIO_P6DIR.B5;
var LCD_D5_Direction : sbit; sfr; external; Data 5 direction pin. var LCD_D5_Direction : sbit at DIO_P6DIR.B6;
var LCD_D4_Direction : sbit; sfr; external; Data 4 direction pin. var LCD_D4_Direction : sbit at DIO_P6DIR.B7;

STM32

The following variables must be defined in all projects using Lcd Library : Description : Example :
var LCD_RS : sbit; sfr; external; Register Select line. var LCD_RS : sbit at GPIOD_ODR.B2;
var LCD_EN : sbit; sfr; external; Enable line. var LCD_EN : sbit at GPIOD_ODR.B3;
var LCD_D7 : sbit; sfr; external; Data 7 line. var LCD_D7 : sbit at GPIOD_ODR.B4;
var LCD_D6 : sbit; sfr; external; Data 6 line. var LCD_D6 : sbit at GPIOD_ODR.B5;
var LCD_D5 : sbit; sfr; external; Data 5 line. var LCD_D5 : sbit at GPIOD_ODR.B6;
var LCD_D4 : sbit; sfr; external; Data 4 line. var LCD_D4 : sbit at GPIOD_ODR.B7;

CEC1x02

The following variables must be defined in all projects using Lcd Library : Description : Example :
var LCD_RS : sbit; sfr; external; Register Select line. var LCD_RS : sbit at GPIO_OUTPUT0.B2;
var LCD_EN : sbit; sfr; external; Enable line. var LCD_EN : sbit at GPIO_OUTPUT0.B3;
var LCD_D7 : sbit; sfr; external; Data 7 line. var LCD_D7 : sbit at GPIO_OUTPUT0.B4;
var LCD_D6 : sbit; sfr; external; Data 6 line. var LCD_D6 : sbit at GPIO_OUTPUT0.B5;
var LCD_D5 : sbit; sfr; external; Data 5 line. var LCD_D5 : sbit at GPIO_OUTPUT0.B6;
var LCD_D4 : sbit; sfr; external; Data 4 line. var LCD_D4 : sbit at GPIO_OUTPUT0.B7;

Library Routines

Lcd_Init

Prototype

procedure Lcd_Init();

Description

Initializes Lcd module.

Parameters

None.

Returns

Nothing.

Requires

External dependencies of the library from the top of the page must be defined before using this function.

Example

Stellaris

// LCD module connections
var LCD_RS : sbit at GPIO_PORTA_DATA.B2;
var LCD_EN : sbit at GPIO_PORTA_DATA.B3;
var LCD_D4 : sbit at GPIO_PORTA_DATA.B4;
var LCD_D5 : sbit at GPIO_PORTA_DATA.B5;
var LCD_D6 : sbit at GPIO_PORTA_DATA.B6;
var LCD_D7 : sbit at GPIO_PORTA_DATA.B7;

var LCD_RS_Direction : sbit at GPIO_PORTA_DATA.B2;
var LCD_EN_Direction : sbit at GPIO_PORTA_DATA.B3;
var LCD_D4_Direction : sbit at GPIO_PORTA_DATA.B4;
var LCD_D5_Direction : sbit at GPIO_PORTA_DATA.B5;
var LCD_D6_Direction : sbit at GPIO_PORTA_DATA.B6;
var LCD_D7_Direction : sbit at GPIO_PORTA_DATA.B7;
// End LCD module connections
...
Lcd_Init();

Stellaris

// LCD module connections
var LCD_RS : sbit at DIO_P6OUT.B2;
var LCD_EN : sbit at DIO_P6OUT.B3;
var LCD_D4 : sbit at DIO_P6OUT.B4;
var LCD_D5 : sbit at DIO_P6OUT.B5;
var LCD_D6 : sbit at DIO_P6OUT.B6;
var LCD_D7 : sbit at DIO_P6OUT.B7;

var LCD_RS_Direction : sbit at DIO_P6DIR.B2;
var LCD_EN_Direction : sbit at DIO_P6DIR.B3;
var LCD_D4_Direction : sbit at DIO_P6DIR.B4;
var LCD_D5_Direction : sbit at DIO_P6DIR.B5;
var LCD_D6_Direction : sbit at DIO_P6DIR.B6;
var LCD_D7_Direction : sbit at DIO_P6DIR.B7;
// End LCD module connections
...
Lcd_Init();

STM32

// LCD module connections
var LCD_RS : sbit at GPIOD_ODR.B2;
var LCD_EN : sbit at GPIOD_ODR.B3;
var LCD_D4 : sbit at GPIOD_ODR.B4;
var LCD_D5 : sbit at GPIOD_ODR.B5;
var LCD_D6 : sbit at GPIOD_ODR.B6;
var LCD_D7 : sbit at GPIOD_ODR.B7;
// End LCD module connections
...
Lcd_Init();

CEC1x02

// LCD module connections
sbit LCD_RS at GPIO_OUTPUT0.B2;
sbit LCD_EN at GPIO_OUTPUT0.B3;
sbit LCD_D4 at GPIO_OUTPUT0.B4;
sbit LCD_D5 at GPIO_OUTPUT0.B5;
sbit LCD_D6 at GPIO_OUTPUT0.B6;
sbit LCD_D7 at GPIO_OUTPUT0.B7;
// End LCD module connections
...

Lcd_Init();
Notes

None.

Lcd_Out

Prototype

procedure Lcd_Out(row, column: word; var text: string);

Description

Prints text on Lcd starting from specified position. Both string variables and literals can be passed as a text.

Parameters
  • row: starting position row number
  • column: starting position column number
  • text: text to be written
Returns

Nothing.

Requires

The Lcd module needs to be initialized. See Lcd_Init routine.

Example
// Write text "Hello!" on Lcd starting from row 1, column 3:
Lcd_Out(1, 3, 'Hello!');
Notes

None.

Lcd_Out_Cp

Prototype

procedure Lcd_Out_Cp(var text: string);

Returns

Nothing.

Description

Prints text on Lcd at current cursor position. Both string variables and literals can be passed as a text.

Parameters
  • text: text to be written
Requires

The Lcd module needs to be initialized. See Lcd_Init routine.

Example
// Write text "Here!" at current cursor position:
Lcd_Out_Cp('Here!');
Notes

None.

Lcd_Chr

Prototype

procedure Lcd_Chr(row, column: word, out_char: byte);

Description

Prints character on Lcd at specified position. Both variables and literals can be passed as a character.

Parameters
  • row: writing position row number
  • column: writing position column number
  • out_char: character to be written
Returns

Nothing.

Requires

The Lcd module needs to be initialized. See Lcd_Init routine.

Example
// Write character "i" at row 2, column 3:
Lcd_Chr(2, 3, 'i');
Notes

None.

Lcd_Chr_Cp

Prototype

procedure Lcd_Chr_Cp(out_char: byte);

Description

Prints character on Lcd at current cursor position. Both variables and literals can be passed as a character.

Parameters
  • out_char: character to be written
Returns

Nothing.

Requires

The Lcd module needs to be initialized. See Lcd_Init routine.

Example
// Write character "e" at current cursor position:
Lcd_Chr_Cp('e');
Notes

None.

Lcd_Cmd

Prototype

procedure Lcd_Cmd(out_char: byte);

Description

Sends command to Lcd.

Parameters
  • out_char: command to be sent
Returns

Nothing.

Requires

The Lcd module needs to be initialized. See Lcd_Init table.

Example
// Clear Lcd display:
Lcd_Cmd(_LCD_CLEAR);
Notes

Predefined constants can be passed to the function, see Available Lcd Commands.

Available Lcd Commands

Lcd Command Purpose
_LCD_FIRST_ROW Move cursor to the 1st row
_LCD_SECOND_ROW Move cursor to the 2nd row
_LCD_THIRD_ROW Move cursor to the 3rd row
_LCD_FOURTH_ROW Move cursor to the 4th row
_LCD_CLEAR Clear display
_LCD_RETURN_HOME Return cursor to home position, returns a shifted display to its original position. Display data RAM is unaffected.
_LCD_CURSOR_OFF Turn off cursor
_LCD_UNDERLINE_ON Underline cursor on
_LCD_BLINK_CURSOR_ON Blink cursor on
_LCD_MOVE_CURSOR_LEFT Move cursor left without changing display data RAM
_LCD_MOVE_CURSOR_RIGHT Move cursor right without changing display data RAM
_LCD_TURN_ON Turn Lcd display on
_LCD_TURN_OFF Turn Lcd display off
_LCD_SHIFT_LEFT Shift display left without changing display data RAM
_LCD_SHIFT_RIGHT Shift display right without changing display data RAM