16
AN3419 Getting Started with IAR Embedded Workbench ® for AVR ® Introduction Authors: Alexandru Niculae, Microchip Technologies Inc. Felipe Torrezan, IAR Systems ® AB The purpose of this application note is to guide new users through the required steps to create a C project from scratch in the IAR Embedded Workbench ® for Microchip AVR ® microcontrollers, build it, program the microcontroller, and debug it. To demonstrate this, a simple ‘Hello World’ application that toggles an LED on button press is used as an example. Figure 1. Tool vs. Device Overview IAR Embedded Workbench ® Build AVR ® Development Board Write from Scratch Download from Atmel START Program the device Debug the program Run the program or PROJECT DEVICE This application note illustrates the following: How to create a new project from scratch Description and option settings for compiling the C source code How to set up an ATmega4809 Curiosity Nano board How to use the IAR Embedded Workbench for programming and debugging © 2020 Microchip Technology Inc. Application Note DS00003419A-page 1

Getting Started with IAR Embedded Workbench® for AVR®ww1.microchip.com/downloads/en/Appnotes/AN3419-Getting... · 2020. 3. 4. · 1. Preparations This application note was written

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

  • AN3419 Getting Started with IAR Embedded Workbench® for AVR®

    Introduction

    Authors: Alexandru Niculae, Microchip Technologies Inc.

    Felipe Torrezan, IAR Systems® AB

    The purpose of this application note is to guide new users through the required steps to create a C project fromscratch in the IAR Embedded Workbench® for Microchip AVR® microcontrollers, build it, program the microcontroller,and debug it.

    To demonstrate this, a simple ‘Hello World’ application that toggles an LED on button press is used as an example.

    Figure 1. Tool vs. Device Overview

    IAR Embedded Workbench®

    Build

    AVR® Development Board

    Write from Scratch

    Download from Atmel START

    Program the device

    Debug the programRun the program

    or

    PROJECTDEVICE

    This application note illustrates the following:

    • How to create a new project from scratch• Description and option settings for compiling the C source code• How to set up an ATmega4809 Curiosity Nano board• How to use the IAR Embedded Workbench for programming and debugging

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 1

  • Table of Contents

    Introduction.....................................................................................................................................................1

    1. Preparations............................................................................................................................................3

    2. Getting Started........................................................................................................................................ 4

    2.1. Creating a New Workspace in IAR Embedded Workbench®....................................................... 42.2. Creating a New Project in IAR Embedded Workbench®..............................................................42.3. Setting up Configurations in IAR Embedded Workbench®.......................................................... 72.4. Configure Fuses...........................................................................................................................82.5. Optimization Levels......................................................................................................................92.6. Stack Usage Analysis and Setup............................................................................................... 102.7. Programming and Debugging with IAR Embedded Workbench® for AVR®...............................10

    3. Revision History.................................................................................................................................... 13

    The Microchip Website.................................................................................................................................14

    Product Change Notification Service............................................................................................................14

    Customer Support........................................................................................................................................ 14

    Microchip Devices Code Protection Feature................................................................................................ 14

    Legal Notice................................................................................................................................................. 14

    Trademarks.................................................................................................................................................. 15

    Quality Management System....................................................................................................................... 15

    Worldwide Sales and Service.......................................................................................................................16

    AN3419

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 2

  • 1. PreparationsThis application note was written for the IAR Embedded Workbench for AVR version 7.20. From this point, it isassumed that a functional IDE is already installed. The IAR Embedded Workbench for the AVR installer can bedownloaded directly from the IAR Systems website. This guide was written for an ATmega4809 Curiosity Nanoboard, but the concepts described apply for other AVR devices as well. Also, a basic understanding of programmingand microcontrollers is assumed.

    AN3419Preparations

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 3

    https://www.iar.com/

  • 2. Getting StartedWhen programming, especially as the application grows into several source files, it becomes essential to properlyorganize the project.

    The IAR Embedded Workbench IDE was designed to make it simple to manage C or C++ project contents. Theupper abstraction of the IDE Project Manager is the Workspace. For each Workspace, the users can add one or moreprojects. The projects added in the same workspace could be related to the same product or have something else incommon. Each project has its settings and a list of source files. Create a new workspace, followed by a new project,or add an existing project example to the workspace. This application note has a ZIP file counterpart containing theinitial source file for an application. The ZIP file contents will be extracted and saved to a known location, such as afolder named ‘AVR’ on the desktop.

    2.1 Creating a New Workspace in IAR Embedded Workbench®Open the IAR Embedded Workbench and follow the steps below to make the first project.

    1. Choose File → New Workspace. A blank state IDE that looks like this will appear:Figure 2-1. The IAR Workspace

    2.2 Creating a New Project in IAR Embedded Workbench®After the new workspace was created, it is time to create a new project.

    1. Choose Project → Create New Project…Figure 2-2. Creating a New Project

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 4

  • 2. In the ‘Create New Project’ dialog window, select the Empty project template and press OK.Figure 2-3. Creating a New Empty Project

    3. The next dialog box will appear and ask where the Project File (.ewp) should be saved. Create a new foldernamed ‘AVR’ on the desktop and save the project under it as HelloWorld.ewp.

    4. Extract the HelloWorld.c source file from the supplied ZIP file to the ‘AVR’ folder.5. Right click on the Project Name in the Workspace and choose Add → Add Files….6. Add the HelloWorld.c source file to the HelloWorld project.7. Notice that there is an asterisk right after the Project name in the Workspace window. This means that the

    project has been modified, and the modifications were not saved. Choose File → Save All. The asterisk willnow disappear.Note:  The first time a workspace is saved, add the name of the .eww file.Figure 2-4. Project with HelloWorld.c Added to the HelloWorld Project

    8. Double click the HelloWorld.c source file to open it in the code editor.The source code for this application note is in this file. The purpose of this code is to show some of theinteresting functionalities of the IAR environment.

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 5

  • Note:  The IAR Compiler Manual is a very useful resource that the users can check to see the numerousfeatures of the IAR compiler. The compiler manual is in the IAR Embedded Workbench installation folder,under the avr/doc subfolder.

    Some functionalities of the IAR environment are described in the following sections. These functionalities are alsoused in the code in HelloWorld.c.

    2.2.1 Using EEPROM VariablesStoring and using a variable in EEPROM is done by adding the __eeprom keyword in its declaration. Afterward, thisvariable can be used like any other variable.

    Optionally, specify the address where to save the variable.

    uint8_t __eeprom level @ 0x1400;

    Note:  By default, the EEPROM is erased when programming the device. During development, it might be useful notto erase the EEPROM every time the device is programmed. For this, go to: Project → Options → Atmel-ICE →Atmel-ICE 2 → Preserve EEPROM contents even if the device is reprogrammed.

    Figure 2-5. Preserve EEPROM Contents Even if the Device is Reprogrammed

    2.2.2 Storing Constants in FlashUsing the __flash keyword will make a constant be stored in the Flash memory. This is useful when there is a lot ofprogram memory available but few data memory.

    const char __flash led_state[2][13] = { "LED is off\r\n", "LED is on\r\n" };

    Note:  Just the const keyword itself does not mean the value will be saved in the program memory. It only meansthat the value is constant, and the memory area where it is saved is compiler implementation-specific.

    When using values from the Flash, there is a set of functions equivalent to the standard ones that must be used.These functions are in pgmspace.h. The following table shows a few examples of the equivalent functions to beused with Flash values:

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 6

  • Standard Function Equivalent Function for Program Space Values

    printf printf_Pmemcmp memcmp_Pstrcpy strcpy_Pstrstr strstr_P

    2.2.3 InterruptsTo specify one or several interrupt vectors, use the #pragma vector directive. The __interrupt keywordspecifies interrupt functions.

    #pragma vector = PORTF_PORT_vect__interrupt void PORTF_int(void){ // Interrupt handling code here.}

    2.2.4 printfFor some boards, by default, printf will write to the USART connected to the debugger, which will, in turn, use theCDC to forward data to the Terminal I/O in the IAR Workbench IDE. This is a very useful out-of-the-box conveniencefeature.

    By implementing the size_t __write(int handle, const unsigned char *buf, size_t bufSize)function, printf output can be manually handled.In the compiler manual, the users can find an example of writing the printf output to an LCD port that is I/Omapped. In the example code provided, the __write function still writes to the USART, but the providedimplementation is faster than the default one.

    2.3 Setting up Configurations in IAR Embedded Workbench®The workspace will now contain the ‘HelloWorld’ project where the source file is located.

    The next task is to configure the IAR compiler and linker. By default, the IAR Embedded Workbench for AVR projectsis created with two default configurations: Debug and Release.

    The Debug configuration will result in an executable object file that contains all the necessary information fordebugging, while the Release configuration will result in a binary file with the debug information stripped out.

    The settings for each configuration can be accessed by selecting Project → Options, or by simply pressing ALT + F7in the Workspace window. As the configurations are independent of each other, every step performed in oneconfiguration needs to be performed for the other configuration as well.

    Figure 2-6. Selection of the Active Configuration

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 7

  • 1. Make sure the desired configuration is selected in the drop-down menu on the top of the Workspace window.2. Right click the Project name and choose Options…3. In the ‘General Options’ category, under the Target tab, select the Processor configuration for the device

    which will be used in the project. Select ATmega4809.Note:  When choosing the processor configuration, there are several categories based on families, as well assome Generic Devices.

    Note:  If a new device is not supported, try updating to the last IDE version.4. In the ‘Memory Model’, choose Small.5. Select the Debugger category. Under the Setup tab, select the Atmel-ICE driver.

    Note:  The Curiosity Nano boards have an on-board debugger (nEDBG) compatible with Atmel-ICE, so anactual Atmel-ICE hardware debugger is not necessary in this case.

    6. Accept the changes to the Options for node ‘HelloWorld’ by clicking OK.The same steps will be repeated for the Release configuration, except:

    • In the ‘Debugger’ category, under the Setup tab, leave the driver settings on their defaults. The Releaseconfiguration does not include the debugging symbols; hence it cannot be used on a debugging session.

    Once done, choose File → Save All. Then go back to the Debug Configuration and choose Project → Make tobuild the project, or simply press F7 to perform the same. On every build, the Build Log window pops up,showing warnings and errors. Make sure to get zero errors and zero warnings on the Build Log window for thisbuild.

    Figure 2-7. The Build Log Window can Point Out Errors and Warnings in the Application

    2.4 Configure FusesFuse bits can be used to configure various peripherals (such as the Watchdog Timer or the Brown-out Detector),system settings (such as clock settings) and memory sections.

    To access the fuse setting in the IAR Workbench IDE, go to the menu item Atmel-ICE in the top bar, then selectFuse Handler.

    Figure 2-8. Atmel-ICE Window

    A window where the fuses can be read and programmed will open.

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 8

  • Note:  To see the fuses, a board must be connected.

    Figure 2-9. Fuse Handler Window

    2.5 Optimization LevelsOptimizations control the degree to which the compiler is allowed to improve various aspects of the code, such assize and speed. Depending on the use case, one of these might be improved to the detriment of the other.

    Access Optimizations settings by going to Project → Options → C/C++ Compiler → Optimizations.

    Figure 2-10. Options for Node ‘HelloWorld’

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 9

  • 2.6 Stack Usage Analysis and SetupOne advanced debugging technique is to check stack usage. This might help detect the stack overflow andcorruption issues. The user can enable this analysis from Project → Options → Linker → Stack Usage.

    The stack sections size can be tuned from Project → Options → General Options → System.Figure 2-11. General Options for Node ‘HelloWorld’

    2.7 Programming and Debugging with IAR Embedded Workbench® for AVR®Writing a real-world application without any errors can be difficult. The bigger the application becomes, the higher isthe rate of expected bugs. A successful compilation means that the application complies with the C languagespecifications. The language compliance will not always ensure the correctness of execution. Therefore, debugging isnecessary. This implies a development phase in which bugs are found during the application execution. Thedeveloper will find ways to fix them according to the application requirements. Knowing more debugging techniqueswill make it easier to track defects throughout the code.

    To start a debugging session in the IAR Embedded Workbench for AVR, perform the following:

    1. Connect the USB cable from the PC to the DEBUGGER USB port of the board.2. Verify that the POWER LED is turned on.3. Make sure to have the Debug configuration selected in the Workspace window.4. Choose Project → Download and Debug (CTRL+D) to program the microcontroller and start a debugging

    session. Every time the application is rebuilt, the microcontroller has to be reprogrammed, hence thedebugging session restarted.

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 10

  • Figure 2-12. Breakpoint at the Beginning of main() Function

    Note:  When starting a debugging session, the IAR debugger will automatically set a code breakpoint at thebeginning of the main() function.

    5. Open a terminal program such as Tera Term, select the Curiosity Nano board COM port and set the baud rateto 9600.

    6. In the code editor, scroll down the HelloWorld.c source file until the call to the printf_P function is found.7. To set a new code breakpoint on this line, click the left column of the code editor, as shown below:

    Figure 2-13. A Line Containing a Code Breakpoint

    Note:  The program execution will automatically halt whenever a line containing a code breakpoint is reached.8. Choose Debug → Go (F5) to continue the execution, then press the user button on the board. Notice that the

    execution will be halted on the line in which the code breakpoint has been set.

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 11

  • Figure 2-14. A Green Arrow will Show where the Program Execution Halted

    9. Hitting F5 again will allow the program to continue. Due to a SLEEP instruction in the while block, themicrocontroller will go to Sleep and will not hit the breakpoint again until it wakes from Sleep. Press the userbutton on the board to wake up the microcontroller, and it will then hit the breakpoint again. This step can beperformed as many times as wanted. As the execution continues, compare the LED state of the actual boardagainst the message that appears in the terminal.Figure 2-15. printf Output Sent to the Terminal

    10. Debugging empowers the developers to face what is going on with their applications in detail. Features suchas the code breakpoints can provide the users with hints of what is going on with the code during run-time. Inthis case, there is a mismatch between the actual LED state and the terminal output. Fix this, then rebuild theproject following the previous steps and using what has been learned so far, try to debug it once again.

    AN3419Getting Started

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 12

  • 3. Revision HistoryDoc. Rev. Date Comments

    A 3/2020 Initial version

    AN3419Revision History

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 13

  • The Microchip WebsiteMicrochip provides online support via our website at http://www.microchip.com/. This website is used to make filesand information easily available to customers. Some of the content available includes:

    • Product Support – Data sheets and errata, application notes and sample programs, design resources, user’sguides and hardware support documents, latest software releases and archived software

    • General Technical Support – Frequently Asked Questions (FAQs), technical support requests, onlinediscussion groups, Microchip design partner program member listing

    • Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing ofseminars and events, listings of Microchip sales offices, distributors and factory representatives

    Product Change Notification ServiceMicrochip’s product change notification service helps keep customers current on Microchip products. Subscribers willreceive email notification whenever there are changes, updates, revisions or errata related to a specified productfamily or development tool of interest.

    To register, go to http://www.microchip.com/pcn and follow the registration instructions.

    Customer SupportUsers of Microchip products can receive assistance through several channels:

    • Distributor or Representative• Local Sales Office• Embedded Solutions Engineer (ESE)• Technical Support

    Customers should contact their distributor, representative or ESE for support. Local sales offices are also available tohelp customers. A listing of sales offices and locations is included in this document.

    Technical support is available through the website at: http://www.microchip.com/support

    Microchip Devices Code Protection FeatureNote the following details of the code protection feature on Microchip devices:

    • Microchip products meet the specification contained in their particular Microchip Data Sheet.• Microchip believes that its family of products is one of the most secure families of its kind on the market today,

    when used in the intended manner and under normal conditions.• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these

    methods, to our knowledge, require using the Microchip products in a manner outside the operatingspecifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft ofintellectual property.

    • Microchip is willing to work with the customer who is concerned about the integrity of their code.• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code

    protection does not mean that we are guaranteeing the product as “unbreakable.”

    Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protectionfeatures of our products. Attempts to break Microchip’s code protection feature may be a violation of the DigitalMillennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, youmay have a right to sue for relief under that Act.

    Legal NoticeInformation contained in this publication regarding device applications and the like is provided only for yourconvenience and may be superseded by updates. It is your responsibility to ensure that your application meets with

    AN3419

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 14

    http://www.microchip.com/http://www.microchip.com/pcnhttp://www.microchip.com/support

  • your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHEREXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION,INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY ORFITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchipdevices 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 suchuse. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights unlessotherwise stated.

    TrademarksThe Microchip name and logo, the Microchip logo, Adaptec, AnyRate, AVR, AVR logo, AVR Freaks, BesTime,BitCloud, chipKIT, chipKIT logo, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, HELDO, IGLOO, JukeBlox,KeeLoq, Kleer, LANCheck, LinkMD, maXStylus, maXTouch, MediaLB, megaAVR, Microsemi, Microsemi logo, MOST,MOST logo, MPLAB, OptoLyzer, PackeTime, PIC, picoPower, PICSTART, PIC32 logo, PolarFire, Prochip Designer,QTouch, SAM-BA, SenGenuity, SpyNIC, SST, SST Logo, SuperFlash, Symmetricom, SyncServer, Tachyon,TempTrackr, TimeSource, tinyAVR, UNI/O, Vectron, and XMEGA are registered trademarks of Microchip TechnologyIncorporated in the U.S.A. and other countries.

    APT, ClockWorks, The Embedded Control Solutions Company, EtherSynch, FlashTec, Hyper Speed Control,HyperLight Load, IntelliMOS, Libero, motorBench, mTouch, Powermite 3, Precision Edge, ProASIC, ProASIC Plus,ProASIC Plus logo, Quiet-Wire, SmartFusion, SyncWorld, Temux, TimeCesium, TimeHub, TimePictra, TimeProvider,Vite, WinPath, and ZL are registered trademarks of Microchip Technology Incorporated in the U.S.A.

    Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BlueSky, BodyCom,CodeGuard, CryptoAuthentication, CryptoAutomotive, CryptoCompanion, CryptoController, dsPICDEM,dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP,INICnet, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, memBrain, Mindi, MiWi, MPASM, MPF,MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM,PICDEM.net, PICkit, PICtail, PowerSmart, PureSilicon, QMatrix, REAL ICE, Ripple Blocker, SAM-ICE, Serial QuadI/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense,ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A.and other countries.

    SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.

    The Adaptec logo, Frequency on Demand, Silicon Storage Technology, and Symmcom are registered trademarks ofMicrochip Technology Inc. in other countries.

    GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of MicrochipTechnology Inc., in other countries.

    All other trademarks mentioned herein are property of their respective companies.© 2020, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

    ISBN: 978-1-5224-5709-1

    Quality Management SystemFor information regarding Microchip’s Quality Management Systems, please visit http://www.microchip.com/quality.

    AN3419

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 15

    http://www.microchip.com/quality

  • AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPECorporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200Fax: 480-792-7277Technical Support:http://www.microchip.com/supportWeb Address:http://www.microchip.comAtlantaDuluth, GATel: 678-957-9614Fax: 678-957-1455Austin, TXTel: 512-257-3370BostonWestborough, MATel: 774-760-0087Fax: 774-760-0088ChicagoItasca, ILTel: 630-285-0071Fax: 630-285-0075DallasAddison, TXTel: 972-818-7423Fax: 972-818-2924DetroitNovi, MITel: 248-848-4000Houston, TXTel: 281-894-5983IndianapolisNoblesville, INTel: 317-773-8323Fax: 317-773-5453Tel: 317-536-2380Los AngelesMission Viejo, CATel: 949-462-9523Fax: 949-462-9608Tel: 951-273-7800Raleigh, NCTel: 919-844-7510New York, NYTel: 631-435-6000San Jose, CATel: 408-735-9110Tel: 408-436-4270Canada - TorontoTel: 905-695-1980Fax: 905-695-2078

    Australia - SydneyTel: 61-2-9868-6733China - BeijingTel: 86-10-8569-7000China - ChengduTel: 86-28-8665-5511China - ChongqingTel: 86-23-8980-9588China - DongguanTel: 86-769-8702-9880China - GuangzhouTel: 86-20-8755-8029China - HangzhouTel: 86-571-8792-8115China - Hong Kong SARTel: 852-2943-5100China - NanjingTel: 86-25-8473-2460China - QingdaoTel: 86-532-8502-7355China - ShanghaiTel: 86-21-3326-8000China - ShenyangTel: 86-24-2334-2829China - ShenzhenTel: 86-755-8864-2200China - SuzhouTel: 86-186-6233-1526China - WuhanTel: 86-27-5980-5300China - XianTel: 86-29-8833-7252China - XiamenTel: 86-592-2388138China - ZhuhaiTel: 86-756-3210040

    India - BangaloreTel: 91-80-3090-4444India - New DelhiTel: 91-11-4160-8631India - PuneTel: 91-20-4121-0141Japan - OsakaTel: 81-6-6152-7160Japan - TokyoTel: 81-3-6880- 3770Korea - DaeguTel: 82-53-744-4301Korea - SeoulTel: 82-2-554-7200Malaysia - Kuala LumpurTel: 60-3-7651-7906Malaysia - PenangTel: 60-4-227-8870Philippines - ManilaTel: 63-2-634-9065SingaporeTel: 65-6334-8870Taiwan - Hsin ChuTel: 886-3-577-8366Taiwan - KaohsiungTel: 886-7-213-7830Taiwan - TaipeiTel: 886-2-2508-8600Thailand - BangkokTel: 66-2-694-1351Vietnam - Ho Chi MinhTel: 84-28-5448-2100

    Austria - WelsTel: 43-7242-2244-39Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828Fax: 45-4485-2829Finland - EspooTel: 358-9-4520-820France - ParisTel: 33-1-69-53-63-20Fax: 33-1-69-30-90-79Germany - GarchingTel: 49-8931-9700Germany - HaanTel: 49-2129-3766400Germany - HeilbronnTel: 49-7131-72400Germany - KarlsruheTel: 49-721-625370Germany - MunichTel: 49-89-627-144-0Fax: 49-89-627-144-44Germany - RosenheimTel: 49-8031-354-560Israel - Ra’ananaTel: 972-9-744-7705Italy - MilanTel: 39-0331-742611Fax: 39-0331-466781Italy - PadovaTel: 39-049-7625286Netherlands - DrunenTel: 31-416-690399Fax: 31-416-690340Norway - TrondheimTel: 47-72884388Poland - WarsawTel: 48-22-3325737Romania - BucharestTel: 40-21-407-87-50Spain - MadridTel: 34-91-708-08-90Fax: 34-91-708-08-91Sweden - GothenbergTel: 46-31-704-60-40Sweden - StockholmTel: 46-8-5090-4654UK - WokinghamTel: 44-118-921-5800Fax: 44-118-921-5820

    Worldwide Sales and Service

    © 2020 Microchip Technology Inc. Application Note DS00003419A-page 16

    http://www.microchip.com/supporthttp://www.microchip.com

    IntroductionTable of Contents1. Preparations2. Getting Started2.1. Creating a New Workspace in IAR Embedded Workbench®2.2. Creating a New Project in IAR Embedded Workbench®2.2.1. Using EEPROM Variables2.2.2. Storing Constants in Flash2.2.3. Interrupts2.2.4. printf

    2.3. Setting up Configurations in IAR Embedded Workbench®2.4. Configure Fuses2.5. Optimization Levels2.6. Stack Usage Analysis and Setup2.7. Programming and Debugging with IAR Embedded Workbench® for AVR®

    3. Revision HistoryThe Microchip WebsiteProduct Change Notification ServiceCustomer SupportMicrochip Devices Code Protection FeatureLegal NoticeTrademarksQuality Management SystemWorldwide Sales and Service