AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.



Similar documents
AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

General Porting Considerations. Memory EEPROM XRAM

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C5131A Starter Kit... Software User Guide

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AT91SAM ARM-based Flash MCU. Application Note

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

AT91 ARM Thumb Microcontrollers. Application Note. GNU-Based Software Development on AT91SAM Microcontrollers. 1. Introduction. 2.

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

USB Test Environment ATUSBTEST- SS7400. Summary

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

UM0985 User manual. Developing your STM32VLDISCOVERY application using the IAR Embedded Workbench software. Introduction

USER GUIDE. ZigBit USB Stick User Guide. Introduction

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

USER GUIDE EDBG. Description

2-wire Serial EEPROM AT24C1024. Advance Information

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

AT88CK490 Evaluation Kit

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Two-wire Serial EEPROM AT24C1024 (1)

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

AVR ONE!... Quick-start Guide. EVK Windows 32104B AVR ONE! 02/10

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

UM1790 User manual. Getting started with STM32L053 discovery kit software development tools. Introduction

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

JTAG ICE.... User Guide

Transcription:

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR Features How to open a new workspace and project in IAR Embedded Workbench Description and option settings for compiling the c-code Setting up the STK500 Using AVR Studio for debugging and programming 8-bit Microcontrollers Application Note Introduction The purpose of this application note is to guide new users through the initial settings of IAR Embedded Workbench, and compile a simple C-program. The application note shows setup of a new project to generate a debug target that can be loaded into AVR Studio. AVR Studio is used for both debugging and to download the code into the device installed on the STK500. A simple ledchaser is used as an example, written for the ATmega16. Figure 1. Tools overview. IAR Embedded Workbench AVR Studio STK500 Write and compile projects Debug code Program device Run program Rev.

Preparations This application note is written for the IAR Embedded Workbench 3.20. From this point it s assumed that a working copy of this IDE is installed. Both IAR s homepage www.iar.com and AVRFreaks.net are suitable sources for download. You also need to install AVR Studio. A copy could be downloaded free from www.atmel.com or installed from the cd following the STK500 development board. The development board should be working with it s default settings, so just unpack and follow the instructions given later in this text. Getting Started You have now installed all tools needed for this getting started, as described in preparations. When working with programming in general it s important to have some structure in your coming projects and code. IAR Embedded Workbench is made to support such demands. The upper abstraction of a task is called a workspace, within each workspace you can add projects. The projects added in a workspace could be supporting the same device or have something in common. Each project contains code and settings for each target. So what we need to do is first make a workspace, then add a new project to this workspace. When this is done you should be able to include an application code to your project and make all the settings for the target AVR on your STK500 board. A sample application code is found together with this document, and should be unzipped and saved at a proper location, ex. C:\users\code. Creating a new workspace in IAR Embedded Workbench Open IAR Embedded Workbench. Follow the list below to make your first project, the ledchaser : 1. Click new under the File menu. 2. Select Workspace and click OK. 3. Next dialog is for selecting name of the new workspace, type in ledchase. Set the Save in path to: C:\users\code and hit OK. Your IAR IDE window should now look like that of Figure 2. Figure 2. The IAR Workspace. 2 AVR030

AVR030 Creating a new project in IAR Embedded Workbench When the new workspace is created, you ll see a pane to the left in the IAR window named ledchase. To make a new project, ledchaser, do the following: 1. Click Create new Project under the Project menu. 2. In the next dialog, select the ledchase directory as your working directory, in this case: C:\users\code, and type ledchase in the project name field. 3. Click Add Files under the Project menu, and select the ledchase.c source file. 4. Click the open button and this file will be added to the project. 5. Double click the ledchase.c under the ledchase project, and feel free to resize, move etc. 6. Click Save all in the File menu. Your project is now completed. Figure 3 shows what this will look like in IAR Embedded Workbench. Figure 3. Project with ledchase.c included. Setting up targets in IAR Embedded Workbench You should now have a workspace which contains the ledchase project, where your source file is located. The next step is to tell what you need from the IAR compiler and linker. In this context it s valuable to work with two targets and their configuration. The IAR Embedded Workbench has two default targets; Debug and Release. The Debug target will make an object file that AVR Studio can use for debugging. The Release target will be a binary file for loading into the flash of your selected AVR. The settings for both targets are done under the Project menu. The steps must be repeated twice; once for the Debug target and once for the Release target. 3

Figure 4. Selection of target. Be sure the Debug target is selected, see Figure 4, and go through the list below: 1. Make sure the right target is selected in the drop-down menu of the project box in your IDE. 2. Click Options under the Project menu. 3. In the General category, under the Target pane, select processor configuration for ATmega16. 4. Chose memory model small. 5. Under the Library Configuration pane, check to enable bit-definitions in IOincluded files. 6. Select the XLINK category. 7. Set the output format to Other ubrof8. This produces an object file that AVR Studio will recognize when the project is built. 8. Close the target options dialog by clicking OK. The same steps should be repeated for Release target, except: In step 7, select Other Intel-standard as output format. This setting tells the compiler to make a hex file that can be loaded into the flash. In the ICCAVR category, under the Optimization pane, select Medium optimization. This way the compiler may be optimized for code size or execution speed. Low degree of optimization gives best support for debugging. When this is done, save all once more. Then select the Debug target and click Make in the Project menu or press F7 to build the project. 4 AVR030

AVR030 Setting up the STK500 Before using the STK500 board be sure the power is turned off. The board should be supplied with an ATmega16 16PC microcontroller. If not already installed, carefully insert into the socket marked SCKT3100A3. The microcontroller has a notch that should be pointing the same way as the similar notch found on the socket. When all set, you should inspect that the following jumpers are set: VTARGET: On-board VTARGET supply connected. AREF: On-board Analog Voltage Reference connected. RESET: On-board reset system connected. XTAL1: On-board clock system connected. OSCEL: Between pin 2 and 3. Enables software clock signal. Remove any other jumpers. Figure 5. Jumpers on stk500 For further reading on this subject, please consult AVR Studio help under STK500 User s Guide and Jumper Settings and Special Cabling. Connect the 10-pin ribbon cable between PORTB and LEDs headers. This will allow displaying the state of the ATmega16 s PORTB output. Connect the 6-pin ribbon between ISP6PIN and SPROG3 headers. This will allow the AVR Studio programming the microcontroller. Connect a RS232 cable from your computer to the connector market RS232 CTRL on the STK500 board. Turn power on! Now your jumper section should look like that in Figure 6. 5

Figure 6. Cabling on STK500. Using AVR Studio IAR Embedded Workbench AVR Studio is project based, so debugging and development is done within a project handling your files. Open AVR Studio, and the project manager will be launched, and new projects can be made or old projects loaded. To open the ledchase project: Select open and browse to the file \Debug\Exe\ledchase.dbg in your projects directory. Select AVR Simulator as debug platform and ATmega16 as device. Press Finish The project is now ready to be debugged in the simulator or programmed into an AVR device. Take a moment and read through the ledchaser code. Try understanding what it will do, before simulating or programming. The ledchaser application is just a simple 0 walking on PORTB. 0 is used because the LEDs on the STK500 are in a sink configuration, and will be lit when given a 0 value. 6 AVR030

AVR030 Figure 7. AVR Studio. AVR Studio is Windows based, and its editor GUI can be divided into four main sections, as seen in Figure 7. A. The Workspace contains information about the files in the project, IO view, and info about the selected AVR. B. The editor contains the code being edited or debugged. C. The output window displays status information while the System Tray displays information about which mode AVR Studio is running in. D. Menus included standard Windows menus like save and load file, cut & paste, and other AVR Studio specific menus like Assembler options and debug functions. The toolbars act as shortcuts to menu functions. Before programming the microcontroller it is valuable using the debugger to verify that the code works. Single step through the code and verify that: 1. PORTB and DDRB is set to 0xFF. 2. See that a PORTB has a running 0. Use Step Into (F11) to see this. See Figure 8 for reference. 7

Figure 8. Tools and I/O view. The code is verified and working, and its time to power up the STK500 board and load the program into the ATmega16. When power is on, a small led in the upper right corner should be lit red. To program the device select STK500/AVRISP/JTAG ICE from the Tools menu. A program manager will pop up, looking like that of Figure 9. 8 AVR030

AVR030 Figure 9. STK500 program window. Make sure that the ATmega16 is selected as device, programming mode is set to ISP and under Flash Use Current Simulator/Emulator FLASH Memory. This will load the current code into device flash. Press the Program button, and wait while the Atmega16 is being programmed. Soon you should see the led start walking. This note is completed and you ve made your very first AVR project, using the IAR Embedded Workbench. For more information regarding IAR Embedded Workbench visit IAR s homepage www.iar.com or have a look at under the help menu. AVR Studio also includes a great source for help. The online help found under AVR Studio s help menu, will solve many problems. Further reading and application notes can be found at www.atmel.com and www.avrfreaks.net. 9

Disclaimer Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON- INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. Atmel Corporation 2004. All rights reserved. Atmel, logo and combinations thereof, AVR, and AVR Studio are registered trademarks, and Everywhere You Are are the trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.