Atmel Studio 7: Adding Dependancies

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

I am transitioning from Arduino to programming microcontrollers in Studio 7. I would like to use FATFS to write data to an SD card, but when I include "ff.h", I get the following message: ff.h no such file or directory 

 

I added the ff.h header file under libraries with no luck, so I suspect ff.h need to show up under Dependencies.

 

Two questions: 

 

  1. Since ff.h does not show under Dependencies, is this causing the error message I'm seeing?
  2. How do I add files to Dependencies?

 

Br,

 

Tim

This topic has a solution.

Tim Watson

Last Edited: Tue. Jan 4, 2022 - 10:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You don't need to add .h files at all in an IDE. That's just a convenience to make access for editing easier. During the build the thing that brings headers into the build are your #include's. When the code has built you'll find any.h that were encountered during the build listed under the "Dependencies" section of the project.

 

The thing you must add to the project to use a collection of code like FatFs are all the .c files needed for the build so ff.c but probably something like mmc_avr.c too. 

 

In 2021 it's unlikely (apart from printf support) that you will ever have need to use the "Libraries" section in Studio 7. True libraries (that is .a archives holding a bunch of .o ELF files) are so "last century" and almost never used and especially not in AVR builds for all the usual reasons. The very fact that to support printf for all models of AVR involves their being 18 copies of each variant rather proves the point! 

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

 

Thank you for the feedback. Can you tell me the steps to take to add the .c files in Atmel/Microchip Studio? For example, right click on library and add library, or right click on include and Add? Is there a specific directory the .c and .h files need to be located in?

 

If I understand correctly, once the .c files are file are added, these will pull in the .h files when #include is compiled.

 

Thanks again for the help!

Tim Watson

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

You just go to the project list of sources. Right click and "add existing". If you want to keep the FatFs in a "central location" that may be used in several projects then when using "Add" click the arrow to the right and use "add as link" instead (otherwise files may be copies over). 

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


 

I'm seeing things working better, i.e. fewer errors and warnings, but there still seems to be an issue somewhere. Below is the code I'm trying to build.

 

/*
 * Test_FATFSLibrary_Rev1.c
 *
 * Created: 12/31/2021 5:33:34 PM
 * Author : Houdini
 */ 

#include <avr/io.h>
#include "diskio.h"
#include "ffconf.h"
#include "ff.h"



int main(void)
{
    /* Replace with your application code */
    while (1) 
    {
    }
}

 

Here's a view of the .h and .c files I've linked to:

 

 

I'm getting the following errors when I try to build this out. It looks like the IDE does not see the ff.h file.?. Any ideas how to fix this and clear these errors?

 

 

Tim Watson

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

There's only one important error there and it's the one about diskio.h. It cannot be found. 

 

By default the preprocessor only searches in the same directory as the file that makes the #include. So if diskio.h is not in the same directory as the file that #include's it that explains the error. You can pass -I to the preprocessor to say "also look here" (possibly multiple directories) so you may need to add that to the search. Studio 7 has a section for adding -I targets called Directories. So try adding the location of diskio.h to that. 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

tim.watson@watsonanalytical.com wrote:
I'm getting the following errors when I try to build this out. It looks like the IDE does not see the ff.h file.?. Any ideas how to fix this and clear these errors?

 

Rather than use that 'Error List' view, you will get more & better information from the 'Output' window:

 

See: https://www.avrfreaks.net/commen...

 

 As to telling the Compiler where to find the include files, see: https://www.avrfreaks.net/commen... for illustrated instructions

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Sat. Jan 1, 2022 - 09:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for sharing this. This was exactly what I needed to resolve this issue and minimized churn in this post. 

Tim Watson