Including Header File In Atmel Studio 6.2.

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

Dear all,

 

First all thanks for such a useful platform.

 

I am new user to the Atmel Studio.

 

I am making a code flash read and write for my project using AVR106. But stuck while including the header file.

I have seen so many people have many queries regardiing this. i am probably doing some silly mistake, hence adding my project here Kindly help me know where I am doing mistake.

 

I have created this project , and add the file, using add file option,  after right clicking over solution. I dont want to add the it the defauld project directory as I may not need these file iin other projects.

so I have added the this file in my current directory, while building the project it is giving build error PAGESIZE not found, main function include the PAGESIZE macros, which define in the .h file.

 

I feel it is not including my .h file at all.  

 

Kindly help me know where I am doing mistake.

 

Rgds

Goswami

Attachment(s): 

Goswami Sourabh,

The Creator....

Last Edited: Mon. Oct 26, 2015 - 05:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I believe Studio ignores header files you put in the project.  You need to add the folder where it's located in the Include Paths.

 

Right click on the project name and then click Properties.  Then click on toolchain, C Directories (or C++ Directories) then spend a while figuring out how to add the folder.  laugh  I think you click on "Add item" icon and then browse.

 

 

 

 

 

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

Or, since you put in in a folder called include, change the #include "Self_programming.h" to #include "Include/Self_programming.h".

 

Or, even better in my opinion, have the c and the h file in the same folder...

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

Thanks Steve and Meolsen,

 

for quick reply...

 

@ Steve... I have already added the includes folder in the directory. Still same error...

 

@Meolsen

 

I have tried to keep the C and H file in same directory, it still gives the problem... see the attachment below..

but the #include "Include/Self_programming.h". this solve my problem... even if include folder is not added in the projet property

 

But I dont understand why it is happened...

I think #include "file.h" will search for the file in the that given directory..... so  error should not come in the attached image also

even the sequence in which file include should not be a problem.....

and why it is necessary to put all the c and H file in same folder.... keep header file and source file seprate make code more readable...

 

Could you help to elobrate it more... where exactly the mistake is...

Goswami Sourabh,

The Creator....

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

Also..Could you please share the ideal directory structure we need to follow in

Atmel Projects... Any documents on that...

 

 

Rgds

Goswami

Goswami Sourabh,

The Creator....

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

That is not a problem with the #include of Self_programming.h . If there was then the compiler would give an error message about the #include failing.

 

What you see is an error because PAGESIZE is not known. For what AVR model are you building this? Is it one of the models known in Self_programming.h ? (By peeking into a makefile in your project it looks like you are building for ATmega328p, and as you can see for yourself if you look into the .h file that AVR model is not handled, so PAGESIZE never gets set:

 

Excerpt from the .h file:

 

#if defined(__ATtiny13__)   || defined(__AT90Tiny13__)   || \
    defined(__ATtiny2313__) || defined(__AT90Tiny2313__)
#define PAGESIZE 32
#endif

#if defined(__ATmega88__)   || defined(__AT90Mega88__)   || \
    defined(__ATmega48__)   || defined(__AT90Mega48__)   || \
    defined(__ATmega8__)    || defined(__AT90Mega8__)    || \
    defined(__ATmega8515__) || defined(__AT90Mega8515__) || \
    defined(__ATmega8535__) || defined(__AT90Mega8535__)
#define PAGESIZE 64
#endif

#if defined(__ATmega162__)  || defined(__AT90Mega162__)  || \
    defined(__ATmega163__)  || defined(__AT90Mega163__)  || \
    defined(__ATmega168__)  || defined(__AT90Mega168__)  || \
    defined(__ATmega169__)  || defined(__AT90Mega169__)  || \
    defined(__ATmega161__)  || defined(__AT90Mega161__)  || \
    defined(__ATmega16__)   || defined(__AT90Mega16__)   || \
    defined(__ATmega32__)   || defined(__AT90Mega32__)   || \
    defined(__ATmega323__)  || defined(__AT90Mega323__)  || \
    defined(__ATmega329__)  || defined(__AT90Mega329__)  || \
    defined(__ATmega3290__) || defined(__AT90Mega3290__)
#define PAGESIZE 128
#endif

#if defined(__ATmega64__)   || defined(__AT90Mega64__)   || \
    defined(__ATmega640__)  || defined(__AT90Mega640__)  || \
    defined(__ATmega649__)  || defined(__AT90Mega649__)  || \
    defined(__ATmega6490__) || defined(__AT90Mega6490__) || \
    defined(__ATmega128__)  || defined(__AT90Mega128__)  || \
    defined(__ATmega1280__) || defined(__AT90Mega1280__) || \
    defined(__ATmega1281__) || defined(__AT90Mega1281__) || \
    defined(__ATmega2560__) || defined(__AT90Mega2560__) || \
    defined(__ATmega2561__) || defined(__AT90Mega2561__)
#define PAGESIZE 256
#endif

 

Where did you get these Self_programming files?

 

(I think that chunk of #if defined's are badly formed. It would be straight-forward to write them in a way that would leave a clear and concise error message if you tried to use it for an AVR model that it does not handle.)

 

goswami sourabh wrote:
Could you please share the ideal directory structure we need to follow in Atmel Projects...

That is not an easy question with one precise answer. It all depends. In your case, the straight-forward solution is what has been suggested: Keep all project files in one and the same folder. (Except that the Self_programming.h file is useless to you since it does not handle your AVR model.)

 

EDIT: How come this thread has a marked solution while there still is discussions on continuing problems? (Can one un-mark a post as the solution?)

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]

Last Edited: Sun. Oct 25, 2015 - 08:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi johan,

I have checked the. H file earlier #define is not present for 328p.. So i have added pagesize above all but nothing happen.. It's like not at all consider. H file..

Even I didnt get why it is given error in only one file not in other c file. Even on doing rebuild all...

This code is from avr106 note. I am just porting it asnper my use...

I understand the structure is depend on invidual.. But wondering if i can get some suggestions..

How different develper following it..

Rgds

Goswami Sourabh,

The Creator....

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

goswami sourabh wrote:
So i have added pagesize above all but nothing happen.. It's like not at all consider.

If you refer to this...

 

 

...then I only see a definition of PAGESIZE that is commented out. (Apart from that, you want to make it a #define and place it in a header file so that all .c source files that want to see it can - without causing any "multiple definition" errors).

 

steve17 wrote:
I believe Studio ignores header files you put in the project

Absolutely not. Just do the include with "quotes" rather than with <angleBrackets>.

 

 

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]