here is my code
//====================================================================== #include <LPC17xx.h> #include "lcd_functions.h"
#include "gpio.h"
int main() { char i,a[]={"Good morning!"}; SystemInit(); //Clock and PLL configuration
GlcdDataBusDirnReg = PortDataBusConfig; // Configure all the Glcd pins as output GlcdCtrlBusDirnReg = PortCtrlBusConfig;
/* Select the Page0/Page1 and turn ON the GLCD */ Glcd_SelectPage0(); Glcd_CmdWrite(0x3f); Glcd_SelectPage1(); Glcd_CmdWrite(0x3f); delay(10);
/* Select the Page0/Page1 and Enable the GLCD */ Glcd_SelectPage0(); Glcd_CmdWrite(0xc0); Glcd_SelectPage1(); Glcd_CmdWrite(0xc0);
Glcd_SelectPage0(); Glcd_CmdWrite(0xB8); // Move the cursor to first line Glcd_CmdWrite(0x40); // Move the cursor to beginning of line
Glcd_DataWrite('H'); Glcd_DataWrite('e'); Glcd_DataWrite('l'); Glcd_DataWrite('l'); Glcd_DataWrite('o'); Glcd_DataWrite(' ');
Glcd_SelectPage1();
Glcd_DataWrite('w'); Glcd_DataWrite('o'); Glcd_DataWrite('r'); Glcd_DataWrite('l'); Glcd_DataWrite('d');
Glcd_SelectPage0(); Glcd_CmdWrite(0xB9); // Move the cursor to second line Glcd_CmdWrite(0x40); // Move the cursor to beginning of line
for(i=0;a[i]!='\0';i++) { Glcd_DataWrite(a[i]); }
while(1); } //================================================================== lcd_functions.c
#include <LPC17xx.h> #include "lcd_functions.h"
void delay(int cnt) { int i; for(i=0;i<cnt;i++); }
/* Function send a complete byte on the Data bus */ void sendByte(char byte) { GlcdDataBusPort&=~(GLCD_dataBusMask); // Clear previous data GlcdDataBusPort|= (((byte >>0x00) & 0x01) << GLCD_D0); GlcdDataBusPort|= (((byte >>0x01) & 0x01) << GLCD_D1); GlcdDataBusPort|= (((byte >>0x02) & 0x01) << GLCD_D2); GlcdDataBusPort|= (((byte >>0x03) & 0x01) << GLCD_D3); GlcdDataBusPort|= (((byte >>0x04) & 0x01) << GLCD_D4); GlcdDataBusPort|= (((byte >>0x05) & 0x01) << GLCD_D5); GlcdDataBusPort|= (((byte >>0x06) & 0x01) << GLCD_D6); GlcdDataBusPort|= (((byte >>0x07) & 0x01) << GLCD_D7); }
/* Function to send the command to Glcd */ void Glcd_CmdWrite(char cmd) { sendByte(cmd); //Send the Command GlcdControlBusPort &= ~(1<<GLCD_RS); // Send LOW pulse on RS pin for selecting Command register GlcdControlBusPort &= ~(1<<GLCD_RW); // Send LOW pulse on RW pin for Write operation GlcdControlBusPort |= (1<<GLCD_EN); // Generate a High-to-low pulse on EN pin delay(1000); GlcdControlBusPort &= ~(1<<GLCD_EN);
delay(10000); }
/* Function to send the data to Glcd */ void Glcd_DataWrite(char dat) { sendByte(dat); //Send the data GlcdControlBusPort |= (1<<GLCD_RS); // Send HIGH pulse on RS pin for selecting data register GlcdControlBusPort &= ~(1<<GLCD_RW); // Send LOW pulse on RW pin for Write operation GlcdControlBusPort |= (1<<GLCD_EN); // Generate a High-to-low pulse on EN pin delay(1000); GlcdControlBusPort &= ~(1<<GLCD_EN);
void Glcd_SelectPage0() { GlcdControlBusPort |= (1<<GLCD_CS1); GlcdControlBusPort &= ~(1<<GLCD_CS2); }
void Glcd_SelectPage1() { GlcdControlBusPort |= (1<<GLCD_CS2); GlcdControlBusPort &= ~(1<<GLCD_CS1); }
//=============================================================================== lcd_functions.h
#include <LPC17xx.h> #include "gpio.h"
//#include<lpc17xx.h>
/* Configure the data bus and Control bus as per the hardware connection */ #define GlcdDataBusPort LPC_GPIO1->FIOPIN #define GlcdControlBusPort LPC_GPIO2->FIOPIN
#define GlcdDataBusDirnReg LPC_GPIO1->FIODIR #define GlcdCtrlBusDirnReg LPC_GPIO2->FIODIR
//#define GLCD_RW GPIO_PinWrite(Rw,Lo)
//#define Hi 1 //#define Lo 0
#define GLCD_D0 P2_0 #define GLCD_D1 P2_1 #define GLCD_D2 P2_2 #define GLCD_D3 P2_3 #define GLCD_D4 P2_4 #define GLCD_D5 P2_5 #define GLCD_D6 P2_6 #define GLCD_D7 P2_7
#define GLCD_RS P0_20 #define GLCD_RW P0_22 #define GLCD_EN P0_21
#define GLCD_CS1 P2_12 #define GLCD_CS2 P2_13
//#define C1_CLR GPIO_PinWrite(C1,Lo)
/* Masks for configuring the DataBus and Control Bus direction */ #define PortDataBusConfig ((1<<GLCD_D0)|(1<<GLCD_D1)|(1<<GLCD_D2)|(1<<GLCD_D3)|(1<<GLCD_D4)|(1<<GLCD_D5)|(1<<GLCD_D6)|(1<<GLCD_D7)) #define PortCtrlBusConfig ((1<<GLCD_RS)|(0<<GLCD_RW)|(1<<GLCD_EN)) #define GLCD_dataBusMask ((1<<GLCD_D0)|(1<<GLCD_D1)|(1<<GLCD_D2)|(1<<GLCD_D3)|(1<<GLCD_D4)|(1<<GLCD_D5)|(1<<GLCD_D6)|(1<<GLCD_D7))
void delay(int cnt); void sendByte(char byte); void Glcd_CmdWrite(char cmd); void Glcd_DataWrite(char dat); void Glcd_SelectPage0(void); void Glcd_SelectPage1(void);
please help me
thank you.