(AVR4029) Atmel Software Framework - Getting Started
(AVR4029) Atmel Software Framework - Getting Started
(AVR4029) Atmel Software Framework - Getting Started
Features
Access to ASF examples Add ASF modules to a project Atmel Studio 6 IAR GNU makefile / GCC
1 Introduction
The Atmel software framework (ASF, www.atmel.com/asf) provides software drivers and libraries to build applications for Atmel megaAVR, AVR XMEGA, AVR UC3 and SAM devices. It has been designed to help develop and glue together the different components of a software design. It can easily integrate into an operating system (OS) or run as a stand-alone product. In this application note developers can read about how to get started with Atmel Studio 6, IAR and GNU GCC makefile: How to install the ASF How to start ASF reference applications How to get ASF documentation It is recommended but not required to read the ASF reference manual for advanced knowledge on the ASF architecture to read this getting started document.
Rev. 8431B-AVR-03/12
2.2 Video
Getting started with a video of Atmel Studio and ASF, follow Atmel videos on http://www.youtube.com/user/AtmelCorporation.
It is possible to sort the ASF examples by kits (for example, Atmel EVK1100, Atmel AVR Xplained), by technology keywords (for example, USB, IO, Interrupt) or by category (drivers, components, services, applications). The example documentation can be viewed by clicking the help icon in the right panel of the New Example Project window. Find the project "USART Example XMEGA-A1 Xplained" and click OK to create it.
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
Figure 2-2. Selecting a new example for a kit.
2. It is now possible to compile, load and debug the project. The Atmel ASF files are imported into a new Atmel Studio project in the src folder. Example files are located in the src/ folder. Dependency files are located in the src/asf/ folder. Connect a debugger to the PC and run the ASF example.
3
8431B-AVR-03/12
3. It is now possible to compile, load and debug the project. The Atmel ASF files are imported into a new Atmel Studio project in the src folder. Example files are located in the src/ folder. Dependency files are located in the src/asf/ folder. Connect a debugger to the PC and run the ASF example. 4. The ASF Explorer is a logical view of ASF code, with easy access to API and documentation.
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
Figure 2-4. ASF Explorer view.
5
8431B-AVR-03/12
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
Figure 2-6. Adding Atmel ASF modules to a project.
2. Select one or several ASF modules, and then click on Add to selection. For example, the timer/counter driver.
7
8431B-AVR-03/12
3. Click on Next, this will summarize the file addition/deletion to the current project. 4. Finally, click on Finish. For example, the RTC Real Time Counter driver rtc.c and rtc.h files are added in the src/asf/xmega/drivers/rtc folder.
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
Figure 2-8. Solution explorer of an ASF example.
9
8431B-AVR-03/12
3. Click OK. Figure 2-10. New user template project for the Atmel XMEGA-A1 Xplained.
10
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
3 Getting started with ASF and IAR Embedded Workbench
3.1 Install
1. 2. 3. 4. Download IAR Embedded Workbench on http://www.iar.com. Install IAR. Download the ASF standalone archive (.zip file) from http://www.atmel.com/asf. Extract the ASF standalone archive on your hard drive (preferably on a location close to the root, to avoid any potential long name length issue on Windows).
11
8431B-AVR-03/12
The services/ folder contains application-oriented pieces of software that are not specific to boards nor chips (for example, FAT, TCP/IP stack, OS, JPEG decoder). For the common/ top folder, the services/ folder also contains chip-specific code The components/ folder offers, for each supported hardware component, a software interface to interact with the component (for example, memories like SDRAM, SD card, or display) The applications/ folder contains hefty examples of applications using services and drivers
12
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
Figure 3-1. IAR project location in the ASF.
13
8431B-AVR-03/12
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
The utils/ folder contains files that are used by all other modules: it holds several linker script files, IAR & GCC pre-compiled libraries of some Atmel ASF modules, and C/C++ utility files with general usage defines, macros and functions The services/ folder contain application-oriented pieces of software that are not specific to boards or chips (for example, FAT, TCP/IP stack, OS, JPEG decoder). For the common/ top folder, the services/ folder also contains chip-specific code The components/ folder offers, for each supported hardware component, a software interface to interact with the component (for example, memories like SDRAM, SD card, or display) The applications/ folder contains hefty examples of applications using services and drivers
15
8431B-AVR-03/12
16
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
.debug_str .debug_loc .debug_macinfo .stack .debug_ranges Total 0x8f0 0x408 0x2b7053 0x1000 0x170 0x2cdce5 0x0 0x0 0x0 0xf000 0x0
text data bss dec hex filename 0x23d8 0x0 0xfffc 74708 123d4 avr32_drivers_gpio_per e_evk1100.elf OBJDUMP avr32_drivers_gpio_peripheral_bus_example_evk1100.lss NM avr32_drivers_gpio_peripheral_bus_example_evk1100.sym OBJCOPY avr32_drivers_gpio_peripheral_bus_example_evk1100.hex OBJCOPY avr32_drivers_gpio_peripheral_bus_example_evk1100.bin
The result of the build is located in the same folder as the makefile location: Elf file (.elf) Listing file (.lss) Symbol file (.sym) Hex file (.hex) Binary file (.bin)
4.6 Programming
4.6.1 Windows users 4.6.1.1 GUI-based solution Launch Atmel Studio Select File->Open->Open Object File for Debugging and select the generated .elf file. Select Next In the Device Selection menu, select the corresponding MCU. Click Finish The project is now available to program and debug. Refer to Atmel Studio getting started and user guide from the welcome screen 4.6.1.2 Command-line based solution for AVR Users Program utilities are installed with Atmel Studio Use atprogram.exe (e.g. in C:\Program Files (x86)\Atmel\Atmel Studio 6.0\avrdbg) as a programmer For example to program an at32uc3b0512 with a JTAGICE3 debugger:
atprogram -t jtagice3 -i jtag -d at32uc3b0512 program -f e:\file.elf
C:\Program Files (x86)\Atmel\Atmel Studio 6.0\avrdbg>atprogram.exe AVR Studio Command Line Interface Copyright (C) 2011 Atmel Corporation.
Usage: atprogram [options] <command> [arguments] [<command> [arguments] ...] Options: -t --tool <arg> Tool name: avrdragon, avrispmk2, avrone, jtagice3, jtagicemkii, qt600, stk500, stk600 or samice.
17
8431B-AVR-03/12
-s
--serialnumber <arg>
The programmer/debugger serialnumber. Must be specified when more than one debugger is connected.
-c
--comport <arg>
-i
--interface <arg>
Physical interface: aWire, debugWIRE, HVPP, HVSP, ISP, JTAG, PDI or TPI.
-d -v -h -p
Device name. E.g. atxmega128a1 or at32uc3a0256. Verbose output (debug). Target host which runs the avrdbg process. Specify which port to use for the avrdbg process. Ignored if the host option is not given.
-f
--force
Force command even if firmware is not up to date. The frequency to use for communication with a device (hz, khz, mhz, default hz). E.g. -cl 10mhz
-xr --externalreset
-dc --daisychain <args,..> Set up a JTAG daisychain. Arguments are <devicesbefore devices-after instr-before instr-after>. -tv --target-voltage <arg> Set the STK600 or STK500 target voltage (float value). -a0 --aref0 <arg> Set the STK600 Aref0 or STK500 aref generator voltage (float value). -a1 --aref1 <arg> Set the STK600 Aref1 generator voltage (float value). -cg --clock-generator <arg> Set the STK600 or STK500 Clock generator frequenc
(hz, khz, mhz, default hz). --timeout <arg> Set the timeout value in seconds for commands. The default is 180 seconds. Set to 0 for no timeout. -q -? --quiet --help Do not display activity indicator. Display help information.
Commands: chiperase erase help info list program read secure verify version write Full erase of chip. Erase the specified memory. Displays help for a specific command. Display information about a device. Detect and print information about connected Atmel Tools. Program device with data from <file>. Read the contents of the memory on the device. Set the security bit on UC3 and ARM devices. Verify content of memory based on a file. Display the version. Write to the memory with values entered on the command line.
18
Atmel AVR4029
8431B-AVR-03/12
Atmel AVR4029
4.6.1.3 Command-line based solution for SAM Users Refer to Atmel SAM-BA In system programmer: http://www.atmel.com/tools/ATMELSAM-BAIN-SYSTEMPROGRAMMER.aspx 4.6.2 Linux users For 8-bit users, use AVRDUDE (http://www.nongnu.org/avrdude/) for MCU programming.
For 32-bit AVR users, refer to AVR32 Studio Users section for a GUI-based solution For ARM users, refer to SAM-BA In (http://www.atmel.com/tools/ATMELSAM-BAINSYSTEMPROGRAMMER.aspx) System programmer
19
8431B-AVR-03/12
5 Table of contents
Features ............................................................................................... 1 1 Introduction ...................................................................................... 1 2 Getting started with ASF and Atmel Studio 6................................ 2
2.1 Install ................................................................................................................... 2 2.2 Video ................................................................................................................... 2 2.3 Start ASF examples ............................................................................................ 2 2.4 Get ASF examples documentation...................................................................... 5 2.5 Add ASF modules to an existing project ............................................................. 6 2.6 Start a new project with a template: User Application Template......................... 9
4.7 AVR32 Studio users .......................................................................................... 19 4.8 Access to project documentation ...................................................................... 19
4.8.1 Online Documentation ............................................................................................. 19 4.8.2 Offline Documentation ............................................................................................. 19
20
Atmel AVR4029
8431B-AVR-03/12
Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com
Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Milennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369
Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621
Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chou-ku, Tokyo 104-0033 JAPAN Tel: (+81) 3523-3551 Fax: (+81) 3523-7581
2012 Atmel Corporation. All rights reserved. Atmel , Atmel logo and combinations thereof, AVR , AVR Studio , megaAVR , SAM-BA , STK , XMEGA , and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Windows and others are registered trademarks or trademarks of Microsoft Corporation in U.S. and or other countries. Other terms and product names may be trademarks of others.
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.
8431B-AVR-03/12