Embedded System


Library for Embedded System

ARM Library

LCD Library for ARM

LCD Open source Header file 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. Note: ARM development system based initialization routines are included in lcd.h. Note: LCD_Config needs RW for checking the LCD busy and this is tested for LPC2148

/media/uploads/anandgembedd/lcd.bmp

Library Routines

  • • LCD_Config
  • • LCD_Out
  • • LCD_Out_Cp
  • • LCD_Chr
  • • LCD_Chr_Cp
  • • LCD_Cmd

LCD_Config

Prototype void LCD_Config(unsigned short *Dport, 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.

Example LCD_Config(&IODIR1, &IOPIN1, 0, 1, 7, 5, 4, 3, 2);

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. Requires Port with LCD must be initialized. See LCD_Config.

Example Print “Hello!” on LCD at line 1, char 3: LCD_Out(1, 3, "Hello!");

LCD_Out_Cp

Prototype void LCD_Out_Cp(char *text); Returns Nothing. Description Prints text on LCD at current cursor position. Both string variables and literals can be passed as text. Requires Port with LCD must be initialized. See LCD_Config.

Example Print “Here!” at current cursor position: LCD_Out_Cp("Here!");

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. Requires Port with LCD must be initialized. See LCD_Config.

Example Print “i” on LCD at line 2, char 3: LCD_Chr(2, 3, 'i');

LCD_Chr_Cp

Prototype void LCD_Chr_Cp(char character); Returns Nothing. Description Prints character on LCD at current cursor position. Both variables and literals can be passed as character. Requires Port with LCD must be initialized. See LCD_Config.

Example Print “e” at current cursor position: LCD_Chr_Cp('e');

LCD_Cmd

Prototype void LCD_Cmd(unsigned short command); 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. Requires Port with LCD must be initialized. See LCD_Config.

Example Clear LCD display: LCD_Cmd(LCD_Clear);

  • Available LCD Commands*
  • LCD Command Purpose
  • LCD_FIRST_ROW Move cursor to 1st row
  • LCD_SECOND_ROW Move cursor to 2nd row
  • LCD_THIRD_ROW Move cursor to 3rd row
  • LCD_FOURTH_ROW Move cursor to 4th row
  • LCD_CLEAR Clear display
  • LCD_RETURN_HOME Return cursor to home position, returns a shifted display to 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

Example:

include the LCD open source Library for ARM

#define CCLK	60	//System Frequency should mentioned for LCD
#define lcd_port IOPIN1	  //LCD Port
#define lcd_port_direction	IODIR1	 //LCD Direction Port
#include <lpc214x.h>
#include <stdio.h> 
#include "lcd.h"	  //LCD Header Files


char *name1 = "Hitech Solutions";
char *name2 = "JAA EmbeddedPark";


void Enable_PLL()
{
PLL0CFG &=~(0x7F);	//For clear 0t06
PLL0CFG |=0x04;		//External OSC 12MHZ so 60/12 =5-1=4
PLL0CFG |=0x01<<5;	//Multipler and divider setup
PLL0CON=0x01;	//Enable PLL
PLL0FEED=0xAA;	//Feed sequence
PLL0FEED=0x55;
while(!(PLL0STAT & 0x0400)); //is locked?
PLL0CON=0x03;	//Connect PLL after PLL is locked
PLL0FEED=0xAA;	//Feed sequence
PLL0FEED=0x55;

}


int main()
{  

Enable_PLL();
 LCD_Config(&lcd_port_direction,&lcd_port,16,18,17,22, 21, 20, 19);	//4bit LCD configuration

 LCD_Cmd(LCD_CLEAR);       // Clear display
 LCD_Cmd(LCD_CURSOR_OFF);  // Turn cursor off

 LCD_Out(1, 1, name1);      // Print text to LCD, 1nd row, 1st column
 LCD_Out(2, 1, name2);      // Print text to LCD, 2nd row, 1st column

 	

 return(0);
}


/media/uploads/anandgembedd/lpc21xx.bmp

/media/uploads/anandgembedd/lcd.h /media/uploads/anandgembedd/main.c


All wikipages