Using AVR® Assembler with MPLAB® X IDE Projects

Consider using the MPLAB® XC8 C Compiler to develop your projects as this compiler toolchain supports AVR devices and assembly code.

Overview

When using the AVR® Assembler, only the main project file should be enabled in the project configuration; all other files should be excluded. The other project files should be included into the main file using the .INCLUDE assembler directive.

Step-by-Step Tutorial

1

Identify the AVR Assembler to MPLAB X IDE

Open MPLAB X IDE and go to Tools > Options > Embedded > Build Tools. Look for "avrasm2" in the Toolchain list. If you do not see it, click Add and locate the file on your computer. The assembler is bundled with Microchip Studio.

2

Create an Assembly Project

Select File > New Project to open the New Project wizard.

  1. Choose Project: Select the Microchip Embedded category and Standalone Project project.
  2. Select Device: Choose an AVR device (ATtiny, ATmega, or ATxmega) from the drop-down list. Then select your debug tool.
  3. Select Header: N/A
  4. Select Plugin Board: N/A
  5. Select Compler: Choose an avrasm2 version from the list (see image).
  6. Select Project Name and Folder: Give your project a name and select a folder location.
NewProject_SelectCompiler.png
Click image to enlarge.

3

Create Assembly Project Files

In the Project tree, right click on the Source Files folder and select New > Other to open the New File wizard (see image).

  1. Choose File Type: Select the Assembler category and AssemblyFile.asm file type.
  2. Name and Location: Give your file a name and select a folder location.

Repeat for each file. Note that once you have created the first file, "AssemblyFile.asm" will appear in the "New" submenu for selection.

ProjectSourceFiles_NewOther.png
Click image to enlarge.

4

Include Only Main File in Project

In the Project tree, right click on the project name and select Properties to open the Project Properties window.

  1. Select the File Inclusion/Exclusion category.
  2. Ensure that only your main file (here called main.asm) is under Included files and all other project files are under Excluded files. To move a file, select it and then click > (see image). To move several files, select them and then click ».

Once files are excluded, they appear grayed in the project tree.

Include_Exclude_Files.png
Click image to enlarge.

5

Use .INCLUDE Directive to Build

Since only the main file is included in the project configuration, the other files will not build until you use the .INCLUDE directive in the main file to include them (see image).

INCLUDE_Directive.png
Click image to enlarge.
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.