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.
- Choose Project: Select the Microchip Embedded category and Standalone Project project.
- Select Device: Choose an AVR device (ATtiny, ATmega, or ATxmega) from the drop-down list. Then select your debug tool.
- Select Header: N/A
- Select Plugin Board: N/A
- Select Compler: Choose an avrasm2 version from the list (see image).
- Select Project Name and Folder: Give your project a name and select a folder location.
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).
- Choose File Type: Select the Assembler category and AssemblyFile.asm file type.
- 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.
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.
- Select the File Inclusion/Exclusion category.
- 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.