Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C
#include <lpc21xx.h>
#include <stdio.h>
#include "lcd.h"
#include "uart.h"
void getstring(unsigned char *);

void status_ok(void);
void main(void)
{
	int i,j,k;
 unsigned int cnt=0x80,m;
 char xx , msg[50];
 Serial_Init();
 delay(50);
uart0_init();
initLCD();
 while(1)
 {
 uart0_tx("AT\r"); // AT COMMAND FOR INITIALING
 status_ok();
 uart0_tx("AT+IPR=9600\r"); // AT COMMAND FOR BAUD RATE
 status_ok();
 uart0_tx("AT+CMGR=2\r"); // Reading the message detail
// at Index 1 with phone number, data and time
 status_ok();
 delay(250);
for(i=0;i<50;)
{
msg[i++]= uart0_rx(); // receieving the message and storing it in the array.
}
msg[i]= '\0';

for( i=0,k=j;i<16;i++)
	{
		LCD_Cmd(0x80+i);
		LCD_WriteString(msg);
		
		if(i+j>16)
		{
			k--;
			LCD_Cmd(0x80);
			LCD_WriteString(msg + k);
		}
		delay(1000);
		LCD_Cmd(0x01);
		
	}
}
}

void getstring(unsigned char *array)
{
 unsigned char temp=0, i=0;
 do
 {
 temp = getchar();
 *array++ = temp;
 }
 while((temp != '\r') && (temp != '\n'));
 *array = '\0';

}
void status_ok(void)
{
	unsigned char *y;
	 char *pointr;
 getstring(y);
 while(!(strstr(y,"OK"))) getstring(y);
* pointr = strstr(y,"OK");
 LCD_Cmd(0xc0);
 LCD_WriteString(pointr++);
 LCD_WriteString(pointr);
 delay(500);
 LCD_Cmd(0x01);

}


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

//lcd.h program//
--------------------

#include <lpc214x.h>
//#include <delay.h>

/*
 Connections from LPC2148 to LCD Module:
 P0.0 to P0.7 used as Data bits.
 P1.16 connected to pin4 i.e. RS	- Command / Data
 P1.17 connected to pin6 i.e. E - Enable
 Pin5 of LCD Module i.e. 'R/W' connected to ground
*/	

void initLCD(void);
void enable(void);
void LCD_WriteChar(char c);
void LCD_WriteString(char * string);
void LCD_Cmd(unsigned int cmd);

void initLCD(void)
{
	IO0DIR = 0xFF; //P0.0 to P0.7 configured as Output - Using 8 Bit mode
	IO1DIR |= (1<<16) | (1<<17); //P1.16 and P1.17 configured as Output - Control Pins
	IO0PIN = 0x0; //Reset Port0 to 0.	
	IO1PIN = 0x0; //Reset Port1 to 0 - Which also makes RS and Enable LOW.

	//LCD Initialization Sequence Now starts
  delay(50);//Initial Delay
	LCD_Cmd(0x3C); //Function Set Command : 8 Bit Mode , 2 Rows , 5x10 Font Style
	LCD_Cmd(0x0F); //Display Switch Command : Display on , Cursor on , Blink on
	LCD_Cmd(0x06); //Input Set : Increment Mode 
	LCD_Cmd(0x01); //Screen Clear Command , Cursor at Home
	LCD_Cmd(0x80); //Not required the 1st time but needed to reposition the cursor at home after Clearing Screen 
	//Done!
}

void enable(void)
{
	delay(50);
	IO1PIN |=  (1<<17);//Enable=High
	delay(50);
	IO1PIN &= ~(1<<17);//Enable=Low
	delay(50);
}

void LCD_WriteChar(char c)
{
	IO1PIN |= (1<<16); //Switch to Data Mode
	IO0PIN = (int) c; //Supply Character Code
	enable(); //Pulse Enable to process it
}

void LCD_WriteString(char *str)
{
	int c=0;
	while (str[c]!='\0')
	{
		LCD_WriteChar(str[c]);
		c++;
	}
}
		
void LCD_Cmd(unsigned int cmd)
{
	IO1PIN = 0x0; //Enter Instruction Mode
	IO0PIN = cmd; //Supply Instruction/Command Code
	enable(); //Pulse Enable to process it
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------

//delay.h program//

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



void delay(unsigned int n)
{
 unsigned int i,j;
 for(i=0;i<n;i++)
 {
 for(j=0;j<12000;j++)
 {;}
 }
}



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


//uart.h program//
---------------------



unsigned char uart_rx()
{
unsigned char str;
while(!(U0LSR&0x20));//wait till kbr contains valid data
str=U0RBR;

	return str;
}
void uart0_tx(string a)----------//error identifier 'string' is undefined//
{
U0THR=a;
while(!(U0LSR & 0x26));
}
void uart_string(char*str)
{
while(*str)
uart0_tx(*str++);
}
uart0_init()
{
U0LSR=0x83;
U0DLL=0x61;
U0DLM=0x00;
U0LCR=0x03;
}


What I have tried:

tried correcting errors.please help us.
Posted
Updated 10-May-17 21:39pm
v2

1 solution

C
void uart0_tx(string a)----------//error identifier 'string' is undefined//
string is not a standard C type and has been nowhere defined in your code.

It looks like the function is transmitting a single character. Then
void uart0_tx(unsigned char a)
should do the job.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900