#Getting Started Microchip Studio for AVR and SAM Devices 

<abstract>
This guide illustrates how to get started with the Yarm development boqrd and 
Microchip Studio for AVR® and SAM Devices
</abstract>

##Step 1: Install Microchip Studio

<blockquote markdown="1">
Microchip Studio for AVR® and SAM Devices (ex Atmel Studio 7)
is an Integrated Development Environment (IDE) used to program 
the Microchip CPU mounted on the Yarm radio module.

To execute it it's requested a modern Windows PC

Microchip Studio for AVR® and SAM Devices includes the Atmel Software Framework (ASF), a large library 
of free source code with about 1,600 project examples.

<a href="https://www.microchip.com/en-us/tools-resources/develop/microchip-studio" target="_blank">
<img width="280px" src="./microchip_studio.jpg">
</a>

[Download Microchip Studio for AVR® and SAM Devices](https://www.microchip.com/en-us/tools-resources/develop/microchip-studio)
</blockquote>

##Step 2: Create you first project

<blockquote markdown="1">
Launch Microchip Studio 7 then select <i>File -> New -> Project</i>. 

Click on <i>GCC C ASF Board Project</i> and type a name for your new project 
then press <kbd>OK</kbd>.

<img class="img-responsive center-block" width="80%" src="./newproject_form.jpg">

After a while a form titled "<i>Board Selection</i>" will appear. 

Select <i>SAML21</i> from the <i>Device Family</i> drop down menu and <i>ATSAML21E18B</i> 
from the related device list then press <kbd>OK</kbd>.

<img class="img-responsive center-block" width="80%" src="./board_selection_form.jpg">

The new project is created with a minimal set of files.

<img class="img-responsive center-block" width="40%" src="./project_tree.jpg">

Click on <i>src</i> folder and then double click on <i>main.c</i> to open the source template generated by Atmel Studio.

<img class="img-responsive center-block" width="80%" src="./main.jpg">
</blockquote>

##Step 3: Add the ASF libraries required by your project

<blockquote markdown="1">

* Read this article: @article='yarm_asf_minimal_set'

</blockquote>

##Step 4: Write your code

<blockquote markdown="1">
Change the default <i>main.c</i> generated by Atmel with this blinking led code example:

@source='main.c'

Wire a led to the YARM-DEV board as shown below:

<img class="img-responsive center-block" width="60%" src="./yarm-led.jpg">


</blockquote>

##Step 5: Launch the compilation

<blockquote markdown="1">
Now launch the C compiler by selecting: <b>Build -> Compile</b>.

The output windows will show:

<pre class="minicom">
Build started.
Project "YarmFirstProject.cproj" (Compile target(s)):
Target "Compile" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "c:\users\tanzilli\Documents\Atmel Studio\7.0\YarmFirstProject\YarmFirstProject\YarmFirstProject.cproj" (entry point):
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe "src/main.o" 
		make: 'src/main.o' is up to date.
	Done executing task "RunCompilerTask".
Done building target "Compile" in project "YarmFirstProject.cproj".
Done building project "YarmFirstProject.cproj".

<b>Build succeeded</b>.
</pre>
</blockquote>

##Step 6: Set up the Atmel ICE in-circuit programer/debbugger

<blockquote markdown="1">
* Plug the ATME-ICE-BASIC programmer on an USB port of your Windows PC and wait until 
the Atmel driver has been installed correctly.
* Select the Atmel Studio menu <i>Tools -> Device Programming</i> 
* Select the tool <i>Atmel-ICE...</i> and the device <i>ATSAML21E18B</i> then press <kbd>Apply</kbd>

<img class="img-responsive center-block" width="80%"  src="./tool-selection.jpg">

* Connect the YARM-2-ICE adapter and the YARM-DEV board as shown below:

<img class="img-responsive center-block" width="80%" src="./yarm-dev-setup.jpg">

* Move the switch on the YARM-2-ICE adapter on <i>SAM</i> position

<img class="img-responsive center-block" width="60%" src="./switch-to-sam.jpg">

* Press the <kbd>Read</kbd> button then, if everything goes well, the <i>Device signature</i> will appear. In not 
be surethat the YARM-DEV boar is plugged to the USB port and to the YARM-2-ICE adapter.

<img class="img-responsive center-block" width="80%"  src="./device-read.jpg">

<br/>

* Press the <kbd>Close</kbd> button and select the menu <i>Debug --> Start Without Debugging</i> to launch the program execution.
</blockquote>

##Links

To know more about the ATA8510 programming read this article:

* @article='yarm_avr_programming'

More info about Yarm are available on:

* @article='doc_yarm'


<a class="btn btn-primary" href="/catalog_yarm" target="_blank"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Buy </a>

@include='bio_tanzilli'
