8.3.2 IAR Settings

The compiler, linker, and assembler settings shown below are required while configuring for a specific device in IAR.

  1. When using the mEDBG in the ATmega328PB Xplained Mini kit, the Atmel-ICE should be selected in Debugger Driver setting (as shown in the figure below).
    Figure 8-6. Debugger Driver
  2. A user-defined .xcl file should be used to override default linker file. Follow the steps below to make the linker work properly:
    1. Copy the template linker file (for example, C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.4\avr\src\template\cfgm328pb.xcl) according to the device to your project and rename it what you like.
    2. Open this file and paste the below content under the original content and save it.
      -ca90
      -w29
      
      
      //=============================================================================
      // Interrupt vectors
      
      -Z(CODE)INTVEC=BOOT_START-(BOOT_START+_..X_INTVEC_SIZE-1)
      //-H1895 
      -h(CODE)BOOT_START-(BOOT_START+_..X_INTVEC_SIZE-1)
      
      //=============================================================================
      // Code memory
      
      -Z(CODE)NEAR_F,HUGE_F,SWITCH,INITTAB,DIFUNCT,CODE=BOOT_START-_..X_FLASH_END
      -Z(FARCODE)FAR_F,FARCODE=BOOT_START-_..X_FLASH_END
      
      
      //=============================================================================
      // RAM
      -Z(DATA)NEAR_I,NEAR_Z=_..X_SRAM_BASE-_..X_SRAM_END
      -Z(DATA)RSTACK+_..X_RSTACK_SIZE=(_..X_SRAM_END-_..X_RSTACK_SIZE+1)-_..X_SRAM_END
      -Z(DATA)CSTACK+_..X_CSTACK_SIZE=(_..X_SRAM_END-_..X_RSTACK_SIZE-_..X_CSTACK_SIZE+1)-(_..X_SRAM_END-_..X_RSTACK_SIZE)
      //-Z(DATA)RSTACK+40=(_..X_SRAM_END-40+1)-_..X_SRAM_END
      //-Z(DATA)CSTACK+300=(_..X_SRAM_END-40-300+1)-(_..X_SRAM_END-40)
      //-Z(DATA)TINY_I,TINY_Z,TINY_N=RAM_BASE-FF
      //-Z(DATA)TINY_I,TINY_Z,TINY_N=RAM_BASE-100
      
    3. Use this file to override the default linker file (as shown in the figure below).
      Figure 8-7. Override Default Linker File
    4. Define BOOT_START (refer to Table 8-1) according to the device (as shown in the figure below).
      Figure 8-8. Linker #define
  3. Optimization Settings (as shown in the figure below).
    Figure 8-9. Optimization Settings