0% found this document useful (0 votes)
2 views6 pages

LCD Program

The document contains a program developed for an LPC2148 microcontroller that reads input from a 4x4 matrix keypad and displays the pressed key on an LCD. It includes the main program, delay routines, and LCD routines necessary for initialization and display functions. The delay functions provide precise timing for operations, with specific implementations for delays in microseconds and milliseconds.

Uploaded by

saiananthi2020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

LCD Program

The document contains a program developed for an LPC2148 microcontroller that reads input from a 4x4 matrix keypad and displays the pressed key on an LCD. It includes the main program, delay routines, and LCD routines necessary for initialization and display functions. The delay functions provide precise timing for operations, with specific implementations for delays in microseconds and milliseconds.

Uploaded by

saiananthi2020
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LCD PROGRAM

MAIN PROGRAM

/**************************************************************************
***

DEVELOPED BY:- ARK DEVELOPER

WHAT PROGRAM DO:-This Program read key from 4x4matrix KeyPad and display
pressed key to LCD.

***************************************************************************
***/

#include "LPC214x.h" /* LPC21xx definitions */

#include "lcd.h" // User defined LCD library which conatins the lcd
routines

#include "delay.h" // User defined library which conatins the delay


routines

/**************************************************************************
***

** Main Function main()

***************************************************************************
***/

int main (void)

/* Initilize the lcd before displaying any thing on the lcd */

LCD_Init();

LCD_GoToLineOne();

LCD_DisplayString("COLLEGE");

delay_mSec(2000);

while(1)

}
}

DELAY.H

#ifndef _DELAY_H

#define _DELAY_H

void delay_mSec(int);

void delay_10uSec(void);

void delay_100uSec(void);

#endif

LCD.H

#ifndef _LCD_H

#define _LCD_H

#define P0_12 (1 << 12)

#define P0_13 (1 << 13)

#define P0_15 (1 << 15)

#define P0_16 (1 << 16)

#define P0_17 (1 << 17)

#define P0_18 (1 << 18)

#define LCD_RS P0_12

#define LCD_EN P0_13

#define LCD_D4 P0_15

#define LCD_D5 P0_16

#define LCD_D6 P0_17

#define LCD_D7 P0_18

#define LCD_DATA_MASK (LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)

#define LCD_DATA_SHIFT 15

//#define LED_LATCH P0_5

//#define LCD_LATCH P0_7


#ifndef LED_DRIVER_OUTPUT_EN

#define LED_DRIVER_OUTPUT_EN (1 << 5) // P0.5

#endif

#ifndef LCD_DRIVER_OUTPUT_EN

#define LCD_DRIVER_OUTPUT_EN (1 << 7) // P0.7

#endif

/*-------------------------------------------------------------------------
---------*/

void set_lcd_port_output( void );

void LCD_Init(void);

void LCD_EnablePulse(void);

void LCD_CmdWrite(char);

void LCD_DataWrite(char);

void LCD_Clear(void);

void LCD_GoToLineOne(void);

void LCD_GoToLineTwo(void);

void LCD_GoToXY(char, char);

void LCD_DisplayString(char *);

void LCD_ScrollMessage(char *);

void LCD_DisplayNumber(unsigned int);

void LCD_DisplayRtcTime(char, char, char);

void LCD_DisplayRtcDate(char, char, int);

void LCD_ClearLineTwo(void);

#endif

DELAY.C

/*-------------------------------------------------------------------------
---------
ARK-LPC2148 delay library with the crystal frequency 12MHz

Filename: delay.c

Controller: LPC2148(ARM7 family)

Oscillator: 12.0 MHz

Author: Prabhu.S

#include "delay.h"

/*-------------------------------------------------------------------------
---------

void delay_10uSec(void)

--------------------------------------------------------------------------
--------

* Return value : none

* description :

This function is used generate a approximate delay in 10uSec.

---------------------------------------------------------------------------
--------*/

void delay_10uSec(void) // pr_note:~10 uSec

int j=0,i=0;

for(j=0;j<10;j++)

/* At 60Mhz, the below loop introduces

delay of 10 us */

for(i=0;i<10;i++);

/*-------------------------------------------------------------------------
---------

void delay_100uSec(void)
--------------------------------------------------------------------------
--------

* Return value : none

* description :

This function is used generate a approximate delay in 100uSec.

---------------------------------------------------------------------------
--------*/

void delay_100uSec(void) // pr_note:~100 uSec

int j=0,i=0;

for(j=0;j<100;j++)

/* At 60Mhz, the below loop introduces

delay of 10 us */

for(i=0;i<10;i++);

/*-------------------------------------------------------------------------
---------

void delay_mSec(int dCnt)

--------------------------------------------------------------------------
---------

* I/P Arguments: int

* Return value : none

* description:

This function is used generate delay in ms.

It genarates a approximate delay of 1ms for each count,

if 1000 is passed as the argument then it generates delay of apprx


1000ms(1sec)
---------------------------------------------------------------------------
--------*/

void delay_mSec(int dCnt) // pr_note:~dCnt mSec

int j=0,i=0;

while(dCnt--)

for(j=0;j<1000;j++)

/* At 60Mhz, the below loop introduces

delay of 10 us */

for(i=0;i<10;i++);

You might also like