Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

error in LCD header file

Status
Not open for further replies.

Saket Karve

Newbie level 1
Joined
Dec 12, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
22
this is the header file i got when i brought a line follower kit which has P89V51RD2FN 8051 based microcontroller.....please let me know whats the mistake



Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//LCD Header
 
#ifndef __LCD_H__
#define __LCD_H__
 
 
 
#define RS P00                                      /*0 for Command , 1 for Data */
#define RW P01                                      /*0 for Write , 1 for Read */
#define EN P02                                      /*Pulsed for completing an operation */
code unsigned char PUTLINE2 = 0x0C0;                /*Address for line 2 */
code unsigned char PUTLINE1 = 0x80;                 /*Address for line 1 */
code unsigned char DISPON = 0x0c;                   /*Command turning on display*/
code unsigned char CURSORHOME = 0x02;/*Command for puttin cursor on home position*/
#include<reg51.h>
#include<delay.h>
void LCD_WRITE(unsigned char dat);
void LCD_CMD(unsigned char cmd);
 
void PULSE(void)
{
    P02 = 1;
    delay(5);
    EN=0;
}
 
void LCD_CMD(unsigned char cmd)     // Give Command to LCD
{
    
    P0=0x00;
    EN=0;
    RS=0;
    RW=0;
 
    P0=((cmd&0xF0))|(0x08);         // Higher nibble first
    PULSE();
 
    P0=(((cmd&(0x0F))*16))|(0x08)// Lower nibble next
    PULSE();
 
 
}
 
 
 
 
void LCD_STRING (unsigned char str[17])
{
    unsigned char k=0;
    P0=0x01;
    EN=0;
    RS=1;                                   //Operation is data write
    RW=0;
    
    while(str[k]!='\0')                     //Till null character is encountered
        {
            P0=((str[k])&0xF0)|0x09;
            PULSE();
            P0=((str[k]&(0x0F))*16)|0x09;
            PULSE();
            k++;
        }
}
 
void LCD_WRITE(unsigned char dat)
{
    unsigned char datH=0,datL=0;
    P0=0x01;
    EN=0;
    RS=1;                                   //Operation is data write
    RW=0;
    
    P0=(dat&0xF0)|0x09;                     // Higher nibble first
    PULSE();
    
    P0=((dat&(0x0F))*16)|0x09;              // Lower nibble next
    PULSE();
}
 
void LCD_INIT(void)                         //LCD Initialization
{
    EN=0;
    RS=0;
    RW=0;
    P0=0x20;                                //4bit mode
    PULSE();
    LCD_CMD(0x01);
    LCD_CMD(DISPON);
    LCD_CMD(CURSORHOME);    
 
}
/*
void LCD_MENU(unsigned char MAINMENU[2][17],r)
{
    unsigned char m=0,n=0;
    LCD_CMD(PUTLINE1);
    for(m=0;m<2;m++)
        {
                
            for(n=0;MAINMENU[m][n]!='\0';n++)
 
                {
                    LCD_WRITE(MAINMENU[m][n]);
 
                }
            LCD_CMD(PUTLINE2);
                
        }
    
}
*/
void LCD_CLEAR(void)                        //Clear LCD 
{
    LCD_CMD(0x01);
 
}
 
 
void LCD_DATA(unsigned char num)
 {
    unsigned char array[3];
    int j=0;
    array[2]=0;
    array[1]=0;
    array[0]=0;
   
    while(num>0)
    {
        array[j]=num%10;
        num=num/10;
        j++;
    }
    LCD_WRITE(array[2]+48);
    LCD_WRITE(array[1]+48);
    LCD_WRITE(array[0]+48);
 }





error:-

'P02' : Undefined Identifier
for every line where EN, RS & RW is written
 
Last edited by a moderator:

Which compiler you are using if you have nxp chip then include the Phillips header file in place of reg51.h and just try below thing

Code:
                       #define RS P0^0                                      /*0 for Command , 1 for Data */
                       #define RW P0^1                                      /*0 for Write , 1 for Read */
                        #define EN P0^2
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top