Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

working with lcd 1602a with atmega8l 16pu

Status
Not open for further replies.

amarsinghkashyap

Newbie level 1
Joined
Dec 18, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
7
hi I m working with LCD 1602a on atmega8l. i have written a program for displaying some word on lcd. but there is some problem i m facind during compiling my program. There are some error related to undeclared function. can any one help me. Error are shown at the end of program. I m using avr studio 4. and my program is..


Code:
#define F_CPU 1000000UL //  1MHz

#define RW PC_4
#define RS PC_3
#define EN PC_5
#define DATA PB
#define ATMEGA8_H
#include <atmega8.h>
#include <inttypes.h>
#include <avr/io.h>
#include <util/delay.h>
void delay(int n); //universal Delay routine for your code; can be customised for your use.
void s_inst(void); //Send Instruction Function Select routine
void s_data(void); //Send Data Select routine
void s_latch(void); // Latch Data/Instruction on LCD Databus.

void main(void) //Main function


{
int k=0;
char x[4]="HARI"; //you can name it whatever you want.
char y[7]="LAKSHMI"; //You can name it whatever you want.
             RS=0;  //Initialize RS=0 for selecting instruction Send
             RW=0; //Select RW=0 to write Instruction/data on              EN=1; //EN=1 for unlatch. (used at initial condition)
             delay(100000); //some LCDs takes time to initialize at startup
             s_inst(); //Call Instruction Select routine
             DATA=0X38; //Send This instruction on Databus Port 2 on LCD databus.
             s_latch(); //Latch this above instruction 4 times
             s_latch();
             s_latch();
             s_latch();


             DATA=0X0F;// Send Second Instruction on Port 2.
             s_latch();
             DATA=0X10; // Set cursor on line 1. Use 0xC0 to write on line 2.
             s_latch(); //Latch the above instruction 1 time.
             DATA=0X0; //Before changing to write data select. Make port 2 =0x0 so that LCD receives nothing
             s_data(); //Change the input type to Data.(before it was instruction input)
             s_latch();  //Latch the above instruction once.
             for(k=0;k<=4;k++)
             {
                         DATA=x[k];  //It will send x[0]='M' as = 0x4D on Port 2.
                         s_latch(); //Latch the above instruction only once. Or it will clone each character twice if you latch twice.
             }
//to type on line 2 call instruction routine first then send instruction on port 2.
            s_inst(); //Instruction Select routine called
            DATA=0XC0; // Set cursor on line 2. Use 0x10 to write on line 1.
            s_latch();
            DATA=0X0; //Before changing to write data select. Make port 2 =0x0 so that LCD receives nothing
            s_data(); //Change the input type to Data.(before it was instruction input)
            //Now it will show Fernandes on line 2.
            for(k=0;k<=6;k++)
             {
                         DATA=y[k];  //It will send y[0]='F' as = 0x45 on Port 2.
                         s_latch(); //Latch the above instruction only once. Or it will clone each character twice if you latch twice.
             }


             while(1); //infinite loop after completing task
}

void delay(int n) //Universal delay routine
{
 int i=0,j=0;
 for(i=0;i<=n;i++)
 for(j=0;j<=10;j++);
}

void s_inst(void) //Instruction select routine
{
             RS=0;
             RW=0;
}
void s_data(void) // Data select routine
{
            RS=1;
            RW=0;
}
void s_latch(void) // Latch routine
{
            EN=1;
            delay(1000);
            EN=0;
            delay(1000);

}
these error are showing during compiling....................
avr-gcc -mmcu=atmega8 -Wall -gdwarf-2 -Os -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT lcd1.o -MF dep/lcd1.o.d -c ../lcd1.c
../lcd1.c:8:21: error: atmega8.h: No such file or directory
../lcd1.c:17: warning: return type of 'main' is not 'int'
../lcd1.c: In function 'main':
../lcd1.c:24: error: 'PC_3' undeclared (first use in this function)
../lcd1.c:24: error: (Each undeclared identifier is reported only once
../lcd1.c:24: error: for each function it appears in.)
../lcd1.c:25: error: 'PC_4' undeclared (first use in this function)
../lcd1.c:26: warning: overflow in implicit constant conversion
../lcd1.c:28: error: 'PB' undeclared (first use in this function)
../lcd1.c: In function 's_inst':
../lcd1.c:73: error: 'PC_3' undeclared (first use in this function)
../lcd1.c:74: error: 'PC_4' undeclared (first use in this function)
../lcd1.c: In function 's_data':
../lcd1.c:78: error: 'PC_3' undeclared (first use in this function)
../lcd1.c:79: error: 'PC_4' undeclared (first use in this function)
../lcd1.c: In function 's_latch':
../lcd1.c:83: error: 'PC_5' undeclared (first use in this function)
make: *** [lcd1.o] Error 1
Build failed with 11 errors and 2 warnings...
 
Last edited by a moderator:

ark5230

Advanced Member level 3
Joined
Jun 29, 2009
Messages
858
Helped
163
Reputation
324
Reaction score
140
Trophy points
1,323
Location
India
Activity points
6,143
Atmega8.h file is not available at proper path, try including in current directory.
The port pins PC_3 etc are not resolved, try writing PC3.
You are using delay.h, it has better routines like _delay_ms() for reliable delays.
Will it be useful if a working c code for same application implementation is available?
 
Last edited:

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top