Unable to compile my LCD programme in AVR Sudio 4.19

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi. I am newbie to embedded system.I have written my 1st LCD code in AVR Studio 4.19 as instructed in [TUT]LCD Tutorial & I downloded Peter Fleury's header file from here. I attached the header file as instructed in [TUT]Adding source and header files efficiently in Studio.

I do necessary changes in lcd header file.
clk 1MHz & I/O mode=1(4bit mode)
My target uC is Atmega8.

My code:

#include
#include
#include"lcd.h"
int main (void)
{
   lcd_init(LCD_DISP_ON CURSOR);
   while(1)
   {
     lcd_clrscr();
     lcd_home();
     lcd_puts("Hello");
     lcd_gotoxy(0,1);
     lcd_puts("LCD Testing");
     _delay_ms(50);
    }
  return(0);
}

I get this error:

Build started 4.5.2013 at 16:55:17
avr-gcc -mmcu=atmega8 -Wl,-Map=lcD1st.map lcD1st.o     -o lcD1st.elf
lcD1st.o: In function `main':
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:7: undefined reference to `lcd_init'
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:12: undefined reference to `lcd_clrscr'
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:13: undefined reference to `lcd_home'
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:14: undefined reference to `lcd_puts'
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:15: undefined reference to `lcd_gotoxy'
C:\Users\Saikat\Documents\lcD1st\default/../lcD1st.c:16: undefined reference to `lcd_puts'
make: *** [lcD1st.elf] Error 1
Build failed with 6 errors and 0 warnings...

What I have done wrong? What I have missed?
Plz help me to sort my problem.

Thanks

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You must add "lcd.c" to your project.

So you end up with your "main.c" and Fleury's "lcd.c" in your project.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for reply.

Quote:
You must add "lcd.c" to your project.

Sorry I am very new to AVR Studio.Can you tell me how to add? & add as header or lib file?

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do not have 4.19 installed anymore (since it's quite old now), but I believe that in AVR Studio you right-click on the sources folder (the folder that already holds the source file with your main() function. Then you do "Add existing" and browse to the lcd.c file and add it.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes what you have told I tried to do. Plz forgive my foolishness. But I got following errors.

Build started 4.5.2013 at 20:13:55
avr-gcc -I"C:\Users\Saikat\Documents\lcD1st\..\header"  -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99     -DF_CPU=100000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT lcD1st.o -MF dep/lcD1st.o.d  -c  ../lcD1st.c
../lcD1st.c:3:16: error: lcd.h: No such file or directory
../lcD1st.c: In function 'main':
../lcD1st.c:7: warning: implicit declaration of function 'lcd_init'
../lcD1st.c:7: error: 'LCD_DISP_ON_CURSOR' undeclared (first use in this function)
../lcD1st.c:7: error: (Each undeclared identifier is reported only once
../lcD1st.c:7: error: for each function it appears in.)
../lcD1st.c:12: warning: implicit declaration of function 'lcd_clrscr'
../lcD1st.c:13: warning: implicit declaration of function 'lcd_home'
../lcD1st.c:14: warning: implicit declaration of function 'lcd_puts'
../lcD1st.c:15: warning: implicit declaration of function 'lcd_gotoxy'
make: *** [lcD1st.o] Error 1
Build failed with 4 errors and 5 warnings...

Here is my screenshot

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As so often in C all those errors stem from the first. Fix:

../lcD1st.c:3:16: error: lcd.h: No such file or directory 

and you fix the rest. The error is that the compiler cannot find a file called lcd.h in the same directory where this .c file holding main() is located.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

-I"C:\Users\Saikat\Documents\lcD1st\..\header"
looks for headers (specified by
#include ; if you specify by #include "header.h", header.h should be in the current directory)
in :
C:\Users\Saikat\Documents\header
and the name of these headers is surrendered by <>

Where are your files located :
lcd.h
lcd.c
lsD1st.c
?
(I am not at all a windows expert, but you might put them (with a browser such as iexplore, or a command such as cmd.exe and copy) in the same place ....))?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
As so often in C all those errors stem from the first. Fix:

../lcD1st.c:3:16: error: lcd.h: No such file or directory 

and you fix the rest. The error is that the compiler cannot find a file called lcd.h in the same directory where this .c file holding main() is located.

dbrion0606 wrote:
-I"C:\Users\Saikat\Documents\lcD1st\..\header"
looks for headers (specified by
#include ; if you specify by #include "header.h", header.h should be in the current directory)
in :
C:\Users\Saikat\Documents\header
and the name of these headers is surrendered by <>

Where are your files located :
lcd.h
lcd.c
lsD1st.c
?
(I am not at all a windows expert, but you might put them (with a browser such as iexplore, or a command such as cmd.exe and copy) in the same place ....))?

First of all thanks for your answer & kindness to bear such a dumb noob. I will let you know here whatever I will get.
Thanks again.

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned above, you first need to locate all those files(lcd.h, lcd.c, etc...) which the compiler cannot find, then you can do two things; or you place them all in the same main directory, or you can add directory path's; open the project options and in 'Include Directories', add the pad's to your project files.

The last option is always easy if you want to reuse some of your code(API's) for other projects, which you then keep in that(those) same directory(ies).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have done what you have told me. Previous errors are gone. But sorry to say new error massages are appeared.

Build started 5.5.2013 at 08:46:56
avr32-gcc -I"C:\Users\Saikat\Documents\AVR\mylcd\."  -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99      -DF_CPU=100000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT mylcd.o -MF dep/mylcd.o.d  -c  ../mylcd.c
cc1.exe: error: unrecognized command line option "-mmcu=atmega8"
make: *** [mylcd.o] Error 1
Build failed with 1 errors and 0 warnings...

I don't understand this error. I have already selected ATmega8 when new project was created.

Between thanks to all for your support.

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your project uses the wrong compiler, which does not recognize at all the option about the ABR model.

The compiler you are using is the one for AVR-32, i.e. 32-bit AVRs. The actual AVR model seems to be an ATmega8 which is an 8-bit AVR.

As I said, I do not have AVR Studio 4 installed anymore, so I can't tell you how to switch to the correct compiler. Looking at earlier posts where you showed build output the correct compiler is used. So, you must have changed something along the way. Undo that change.

The clue was in the start of the command line:

avr32-gcc ...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At last I have succeeded! My code is compiled & it ran the way what I wished.
Thank you very much to all who helped & bear such a noob like me.
Thanks again.

When you do ask questions, you may look stupid.
When you do NOT ask questions, you will STAY stupid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you fill out your city and country in the profile, you might find other avrfreaks nearby to collaborate with.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It may not matter at this time, but F_CPU is wrong.

 

In consideration of others, please RTFM!