Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro (Read 3593 times)
dexter
Newbies
*
Offline


Posts: 4
Joined: Jan 17th, 2020
Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Feb 5th, 2020 at 1:00pm
Print Post  
Hi. In an Arduino Due project, made using VMicro in the Atmel Studio 7.0, Is there a way to use the ASF Wizard to add libraries under asf.h to the project? so then you can use them such as:

Common IOPORT API library for IO Port manipulation http://asf.atmel.com/docs/latest/samg/html/group__ioport__group.html#gabc09edad7...

Thanks in advance
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #1 - Feb 5th, 2020 at 3:41pm
Print Post  
Not directly but if you have .a lib files you can put them in a \libs folder below the project. They will then be included in the link. Does this help?
  
Back to top
WWW  
IP Logged
 
dexter
Newbies
*
Offline


Posts: 4
Joined: Jan 17th, 2020
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #2 - Feb 5th, 2020 at 4:30pm
Print Post  
Thanks. library files of asf.h could be found, but usually, a number of them are involved together and ASF wizard nicely adds them all and link them together correctly with the main.c (that is if you make a project by Atmel studio itself which then uses a main.c, but through Vmicro, gives the benefit of making project from Arduino .ino files).

It is yet possible to find such a folder after its made by the Atmel Studio and copy it, but doing that cause VMicro not finding the correct links between the libraries of asf.h and not compiling your sketch, probably one reason is there is no such file main.c really in Arduino style projects. That is why I am asking about the ASF Wizard. Atmel libraries are quite awkward to link with other platforms really, but they can be really helpful.
Noticed many people had a similar question around the web, but no one had an answer so far or I couldn't find it.

Also, where is the /lib folder you mentioned exactly?

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #3 - Feb 5th, 2020 at 5:30pm
Print Post  
Thanks, this is very useful info and discussion. It would be good to achieve but possibly not practical, I don't want you to waste your time. Here is some info anyway.

Firstly, a lib folder can be created by you directly below each project folder. Myproj\Libs. Placing .a files in this folder will cause them to be linked. Adding them also to the AS7 projectName > "Libraries" node in the solution explorer will also allow atmel intellisense to use them. (It would be nice if visual micro could simply use the "Libraries" node but unfortenatly atmel pre-adds libs to the node which users don't expect. Therefore the "Libraries" node is just to help intellisense and does not affect compile. Only the extra files in project\Libs are linked)

To add files to an arduino project they must exist in the project folder or the project\src folder or any folder below the project\src folder.

Normally arduino projects use a main.cpp which exists in the platform core. If you add a main.cpp to your project folder then visual micro will use the local one instead of the one in the core. That's a main.cpp not a main.c which might be a problem for you.

To see the original main.cpp for your current core you can click "vMicro>Show hiden files". You will see the main.cpp is responsible for startup and calls your setup() and loop() in your .ino code. You need to copy the main.cpp contents into your new local main.cpp override otherwise your .ino code won't work.

After you have finished reviewing the original main.cpp you can delete the short cuts that Visual Micro added to your project or click the "vMicro>Show hidden files" command again and it will delete them for you. The shortcuts added by that command cause no harm and do not affect compilation but might slow the ide down especially if you frequently switch between different boards in the same project.

Having access to the main.cpp is the closest you get to overriding arduino without breaking it and without creating your own custom core.

I hope this makes sense?







  
Back to top
WWW  
IP Logged
 
dexter
Newbies
*
Offline


Posts: 4
Joined: Jan 17th, 2020
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #4 - Feb 6th, 2020 at 9:56am
Print Post  
Hi, many thanks, I'm going to try what you have suggested and respond back with the results. Thanks

Atmel ASF libraries include .h and .c files as well as .a files, so are they all should be included in the /lib or just the .a?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #5 - Feb 6th, 2020 at 2:01pm
Print Post  
Only .a files in lib.

Normal sources need to be in the project within the "legal" folders I mentioned (pro, src, src/....." or made into Arduino compatible libraries. Arduino compatibile libraries simply means getting the right folder structure

MyLibraries\Lib1\library.properties
MyLibraries\Lib1\src

MyProject\Proj1\Proj1.ino
MyProject\Proj1\src


Libraries can exist anyware but outside of the project folder. Use the visual micro examples in file>new>project area to see how things work.
  
Back to top
WWW  
IP Logged
 
dexter
Newbies
*
Offline


Posts: 4
Joined: Jan 17th, 2020
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #6 - Feb 13th, 2020 at 12:47pm
Print Post  
I have managed to try the suggestions (thanks again) and after adding a certain .a file (for example the one associated with ioport.c and ioport.h) to the project folder, there comes another bunch of errors asking for another file. You add that and then another... so I can say to use the Atmel asf, there is a chain of files required, and not worth the time as you mentioned, unless someone from Atmel steps in and help! Hence, I tried using a GCC C ASF project instead of using Visual micro and adding the required libraries using Atmel ASF wizard. This one compiles and builds correctly but the actual ASF functions do not exactly behave as expected; I guess there are more to initialise and setup to be able to use them efficiently and after all, they may be not exactly compatible with Arduino and there is not exactly a lot of application notes you can find on this.
I have to say the Arduino's engineers done a good job building libraries compatible with this hardware that may not be the fastest (such as digitalWrite instead of direct pin registers manipulation), but at least operate correctly.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Atmel Studio ASF Wizard in an Arduino Due project made by Vmicro
Reply #7 - Feb 13th, 2020 at 4:13pm
Print Post  
Thanks for the update. I agree with everything that you have said.

Yes digitalWrite is slow but it is portable which makes it possible to upgrade or switch mcu without code changes. All other speedy solutions appear to be architecure dependant.

One lame solution but an improvement: If you look at what the arduino does for digital write I suspect that you can by pass some of their code quite easily. One obvious overhead if when we use digitalWrite(13, HIGH) the 13 first has to be resolved to the read port/pin for the current board. If you wanted to hard code these values I am sure you could then call whatever digitalWrite() calls but without the pin resolver. That would probably speeds things up a lot (but digitalWrite() was just one  example that you made, I know that!  Smiley
« Last Edit: Feb 13th, 2020 at 4:15pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint