Download Assembler/Linker/Librarian User's Guide
Transcript
Sample Applications 13.3 SAMPLE APPLICATION 1 - TEMPLATES AND LINKER SCRIPTS In the MPLAB X IDE or MPLAB IDE v8 installation, assembly source code templates and generic linker script files are provided for most devices supported by the IDE. The source code templates give you a starting point from which to begin coding. The generic linker scripts are used automatically by the linker to simplify application development. Or you may modify a linker script and then manually add it on the linker command line or to the project. This first general example will discuss templates and linker scripts. 13.3.1 Locating Templates and Linker Script Files For MPLAB X IDE or MPLAB IDE v8 installed in the default location, source code templates may be found at: C:\Program Files\Microchip\MPASM Suite\Template in the following subdirectories: • Code - Contains absolute assembly code examples by device • Object - Contains relocatable assembly code examples by device The relocatable source code template 18F8722TMPO.ASM for the PIC18F8722 may be found in the Object directory. This template provides oscillator setup, example variable and EEPROM setup, reset and interrupt handling routines, and a section main for application code. For MPLAB X IDE installed in the default location, the generic linker script files may be found at: C:\Program Files\Microchip\MPASM Suite\LKR The generic linker script file for the PIC18F8722 would be 18f8722_g.lkr. This file defines initialization files, program code sections, GPR sections, and access memory sections. These definitions are grouped based on debugger or programmer usage, and regular or extended memory usage. Program memory sections specified by the template code and linker script are compared below. TABLE 13-4: PROGRAM MEMORY MAP - PIC18F8722 Program Memory Address 0x0000 0x0007 Linker Script Section (Not debug or extended) page - ROM code space Template Source Code Section RESET_VECTOR - Reset vector 0x0008 0x0017 HI_INT_VECTOR - High priority interrupt vector 0x0018 LOW_INT_VECTOR - Low priority interrupt vector 0x0019 0x01FFFF High_Int - High priority interrupt handler Low_Int - Low priority interrupt handler Main - Main application code 0x200000 0x200007 idlocs - ID locations 0x300000 0x30000D config - Configuration bits 0x3FFFFE 0x3FFFFF devid - Device ID 0xF00000 0xF003FF eedata - EEPROM data 1994-2013 Microchip Technology Inc. CONFIG - Configuration settings DATA_EEPROM - Data EEPROM DS33014L-page 261