hex file. The example described in this application note is written for the AT94K using the FPSLIC Starter Kit. Creating a New Project

Similar documents
8-bit Microcontroller. Application Note. AVR030: Getting Started with C for AVR

Preparations. Creating a New Project

8-bit Microcontroller. Application Note. AVR031: Getting Started with ImageCraft C for AVR

AT94K Series Field Programmable System Level Integrated Circuit. Application Note. FPSLIC Baud Rate Generator

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

System Designer. Programmable SLI AT94K/AT94S Series. Features. Description

AVR32 UC3 Software Framework... User Manual

System Designer. Programmable SLI AT94K/AT94S Series. Features. Description

AT17 Series FPGA. Configuration Memory. Application Note. In-System Programming Circuits for AT17 Series Configurators with Atmel and Xilinx FPGAs

FPGA Configuration EEPROM Memory. Application Note. Programming Atmel s EEPROMs: AT17LV020(A) vs. AT17LV002(A) Introduction.

8-bit RISC Microcontroller. Application Note. AVR 305: Half Duplex Compact Software UART

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler

AT89C5131 Starter Kit... Software User Guide

TSC695. Application Note. Annulled Cycle Management on the TSC695. References

8051 Microcontrollers. Application Note. Migration from AT89C5131 & AT89C5131A-L to AT89C5131A-M

Programmable SLI AT40K AT40KAL AT94K. Application Note. Implementing a Single-coefficient Multiplier

AT17(A) Series FPGA Configuration Memory. Application Note

2-wire Serial EEPROM Smart Card Modules AT24C32SC AT24C64SC

Section 1 ATAVRAUTOEK1 Getting Started

AT91 ARM Thumb Microcontrollers. Application Note. AT91M55800A Clock Switching Considerations using Advanced Power Management Controller.

MP3 Player Reference Design Based on AT89C51SND1 Microcontroller... User Guide

FPGA Configurator Programming Kit (Enhanced) ATDH2200E. Features. Description

8-bit Microcontroller. Application Note. AVR033: Getting Started with the CodeVisionAVR C Compiler

Bluetooth General Information White Paper

Application Note Microcontrollers. C Flash Drivers for T89C51RC/RB/IC2 and AT89C51RC/RB/IC2 for Keil Compilers

Rad Hard FPGA. AT40KEL-DK Design Kit Content. Description. Kit Content. Reference Material. Support

Migration From AT89C51SND1C to AT83C51SDN1C. Application Note. MP3 Microcontrollers

Atmel FPGA Integrated Development System (IDS)

ATAVRAUTO User Guide

MARC4. Application Note. Hints and Tips for Hard- and Software Developments with MARC4 Microcontrollers

UART. Embedded RISC Microcontroller Core Peripheral

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

Atmel FPGA Integrated Development System (IDS)

When is Data Susceptible to Corruption

CAN Microcontrollers. Application Note. Migrating from T89C51CC01 to AT89C51CC03. Feature Comparison

1-megabit (64K x 16) 5-volt Only Flash Memory AT49F1024 AT49F1025

AT17F Series. Application Note. Programming Circuits for AT17F Series Configurators with Xilinx FPGAs. 1. Introduction

OrCAD Support for Atmel PLDs. Application Note. OrCAD Support for Atmel PLDs. Overview

Product Description. Application Note. AVR360: XmodemCRC Receive Utility for the AVR. Features. Theory of Operation. Introduction

Application Note. Microcontrollers. Using Keil FlashMon Emulator with AT89C51CC01/03 AT89C51CC01/ Summary. 2. Background overview

Interrupt Controlled UART

AT89STK-09 Starter Kit for AT83C26... User Guide

8-bit Microcontroller. Application Note. AVR320: Software SPI Master

DIP Top View A18 A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND VCC A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3 VCC A18 A17

CAN, 80C51, AVR, Microcontroller. Application Note

Atmel-Synario CPLD/PLD Design Software ATDS1100PC ATDS1120PC ATDS1130PC ATDS1140PC. Features. Description

Secure Microcontrollers for Smart Cards. AT90SC Summary

AT91 ARM Thumb Microcontrollers. Application Note. AT91 Host Flash Loader. 1. Package Contents. 2. Definition of Terms. 3.

ATAVRAUTO User Guide

1-megabit (64K x 16) 3-volt Only Flash Memory AT49LV1024 AT49LV1025

AT17A Series FPGA Configuration EEPROM Memory. Application Note. FPGAs. AT17A Series Conversions from Altera FPGA Serial Configuration Memories

Parallel EEPROM Die Products. Die Products. Features. Description. Testing

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

AT89ISP Programmer Cable Introduction AT89ISP Programmer Cable Parallel Port Settings Application Note AT89ISP Software AT89ISP Cable polarized

8-bit Microcontroller. Application Note. AVR032: Linker Command Files for the IAR ICCA90 Compiler

Getting Started with the IAR Embedded Workbench for FPSLIC. Application Note. Getting Started with the IAR Embedded Workbench for FPSLIC.

Two-wire Serial EEPROM Smart Card Modules 128K (16,384 x 8) 256 (32,768 x 8) AT24C128SC AT24C256SC. Features. Description VCC NC

Interfacing the internal serial EEPROM

4-megabit (512K x 8) Single 2.7-volt Battery-Voltage Flash Memory AT49BV040 AT49LV040

AVR -based Bridge between Full-speed USB and Fast Serial Asynchronous Interfaces AT76C711

80C51 MCUs T89C51AC2. Errata Sheet

Trusted Platform Module AT97SC3203S. SMBus Two-Wire Interface. Summary

Two-wire Serial EEPROM Smart Card Modules 1K (128 x 8) 2K (256 x 8) 4K (512 x 8) 8K (1024 x 8) 16K (2048 x 8)

design cycle involving simulation, synthesis

a Serial Peripheral Interace (SPI). Embedded RISC Microcontroller Core Peripheral

SPI Serial EEPROMs AT25010 AT25020 AT SPI, 1K Serial E 2 PROM

AVR501: Replacing ATtiny15 with ATtiny25. 8-bit Microcontrollers. Application Note PRELIMINARY. Features. 1 Introduction

2-wire Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 AT24C16

Battery-Voltage. 16K (2K x 8) Parallel EEPROMs AT28BV16. Features. Description. Pin Configurations

3-Wire Serial EEPROM AT93C46C

8-bit RISC Microcontroller. Application Note. AVR151: Setup And Use of The SPI

2-Wire Serial EEPROM AT24C01. Features. Description. Pin Configurations. 1K (128 x 8)

2-wire Serial EEPROMs AT24C128 AT24C256

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

SAM Boot Assistant (SAM-BA)... User Guide

AT40K FPGA IP Core AT40K-FFT. Features. Description

2-wire Serial EEPROM AT24C512. Preliminary. 2-Wire Serial EEPROM 512K (65,536 x 8) Features. Description. Pin Configurations.

32-megabit 2.7-volt Only Serial DataFlash AT45DB321. AT45DB321 Preliminary 16- Megabit 2.7-volt Only Serial DataFlash

FPGA Configuration EEPROM Memory AT17C65A AT17LV65A AT17C128A AT17LV128A AT17C256A AT17LV256A

ATICE10... User Guide

CryptoRF EEPROM Memory 8 Kbits

1-megabit 2.7-volt Only Serial DataFlash AT45DB011. AT45DB011 Preliminary 16- Megabit 2.7-volt Only Serial DataFlash

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89C51CC03 UART Bootloader

P_D_OUT[31:0] SPI_INT SPI_MOSI_OUT SPI_MOSI_OEN

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AT89STK-10 Starter Kit... Hardware User Guide

EPROM. Application Note CMOS EPROM. Interfacing Atmel LV/BV EPROMs on a Mixed 3-Volt/5- Volt Data Bus

1-Megabit (128K x 8) Low Voltage Paged Parallel EEPROMs

256 (32K x 8) High-speed Parallel EEPROM AT28HC256N. Features. Description. Pin Configurations

32-bit Embedded Core Peripheral. Cache Memory. and Bus Interface Unit

shown in Figure 3. An example where the command 0x35 is sent to system 5 is shown in Figure 4. Figure 2. RC5 Frame Format Figure 3.

AT89C51SND1 UART Bootloader

2-wire Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 AT24C16

2-wire Serial EEPROM AT24C21. 2-Wire, 1K Serial EEPROM. Features. Description. Not Recommended for New Designs. Pin Configurations.

2-wire Serial EEPROM AT24C512

3-wire Serial EEPROMs AT93C46 AT93C56 AT93C57 AT93C66

2-wire Serial EEPROMs AT24C128 AT24C256. Features. Description. Pin Configurations. 128K (16,384 x 8) 256K (32,768 x 8)

T89C5115 UART Bootloader

ARM7TDMI - based Microcontroller AT91RM3400. Errata Sheet

Transcription:

Getting Started with C for the Family Using the IAR Compiler Features How to Open a New Project Description of Option Settings Linker Command File Examples Writing and Compiling the C Code How to Load the Debug and Executable Hex Files into the System Designer Software Introduction The purpose of this application note is to guide new users through the initial settings of the IAR Embedded Workbench for AVR and compile a simple C program. This application note shows how to set up the compiler to generate a UBROF debug file and an executable hex file. The example described in this application note is written for the AT94K using the Starter Kit. Creating a New Project Open the IAR Embedded Workbench for AVR and go to the File menu and select New and then Project. The dialog box shown in Figure 1 appears. In this dialog box, first make a folder C:\ and then type Getting Started in the File name window. This project should be created in the C:\ folder. 10K - 40K Gates of AT40K FPGA with 8-bit Microcontroller and 36K Bytes of SRAM Application Note Figure 1. Create the Project File Rev. 1977A 11/00 1

Settings in Project > Options Before any code can be compiled and linked, the options for the compiler and linker must be set up correctly. By default, it is possible to select two different targets in the Project window. The two selections are target Release and target Debug. The debug target is normally used when running the code in a simulation environment, while the release target is normally used when producing code that can be executed on a real device. The settings done in the Project > Options menu are individual for both targets. Thus, it is necessary to set all options twice when using both targets, as in this application note. The main difference between the two targets is the format of the output file. It is also possible to add more targets whose options can be customized to a specific (simulated or the real device). Common and different source files may be included in the different targets. A folder will be created for each target when linked for the first time. To set up a common source folder, simply navigate to Project > New Group and enter the name Common Sources in Group Name. By default, both targets are selected, so the group will be added to both targets. After clicking OK, the group will be displayed in the Project window. In this application note, the goal is to make a file that can be imported into System Designer for both simulation and execution on an AT94K device. To do this, both debug and release targets will be used. Select the Debug target in the Getting Started.prj window, as shown in Figure 2. Then select the Project > Options menu. A window similar to the one in Figure 3 should pop up. Figure 2. Selecting Target Debug 2

General Settings In the General category in the Options dialog box, the type of processor used is selected. Under Processor configuration select cpu=at94k, FPslic and choose Small for the Memory model. Memory model: Small uses a 2-byte data pointer, thus allowing up to 64 KB of data. Under System Configuration uncheck the Configure system using dialogs box and select the desired partitioning. For this example, select 32k CODE, 4k DATA. It is necessary to change one other option. Select the General > Library Configuration tab and check the Enable bit definitions in I/O-Include files box. In our example, the settings shown in Figure 3 should be used. Figure 3. General Options Dialog 3

ICCAVR Settings To get the dialog options for the specific settings of the compiler, click on the ICCAVR line in the Category list. The compiler may be optimized for code size or execution speed. The type and level of optimization may be set in the Optimizations group in Figure 4. Only one type of optimization may be specified for a single target. Note that if a high level of optimization is used, the user may not be able to debug the code. The code will be fully debuggable with optimization level of Medium or lower. On the List tab, the user is able to determine whether a C listing is generated, and the information included in this listing. The Assembler mnemonics option will, if checked, cause the compiler to include the generated assembly lines in the listing. It is extremely important that Assembler file is not checked, as this will not allow the proper simulation of the MCU in the System Designer software. Figure 4. ICCAVR Option Settings AAVR Settings In the AAVR settings, the options for the assembler can be changed. Since this application note does not contain any parts written in assembly, the default settings can be left unchanged. 4

XLINK Settings The linker settings give the linker instructions on how to link together the object codes from the different Compiler, Assembler and Library modules. The first thing that needs to be selected is the format of the output file the linker is to create. In this application note, the intention is to generate both a debug[ubrof] and an Intel Extended HEX file, which are recognized by System Designer and the Starter Kit, respectively. Selecting the Output tab of the XLINK options and clicking the Other button in the format section does this. Select intel-extended from the Output format pull-down menu, as shown in Figure 5, if your target is set to Release. Otherwise, select debug[ubrof] from the Output format pull-down menu and select Old UBROF version from the Format variant pull-down menu if your target is set to Debug. In the Output file group it is possible to rename the output file. The default name is the same as the project name. Figure 5. Selecting Output Format 5

The other thing that has to be changed is the Linker Command File used. To change this, click on the Include tab and under the XCL file name bar, check Override default, as shown in Figure 6. Then click the button and navigate to the AT94K-32S.xcl file attached to this application note. Here it is assumed that the file is stored in the C:\ directory. The main purpose of the Linker Command File is to determine the code and data segments, which is done in the Z command. Note that the size of the Data Stack and Return Stack is specified explicitly and may be changed according to a specific project. The Linker Command File will probably need to be edited for each project. The Linker Command Files attached to this application note must be considered as a starting point only. Please see the application note Linker Command Files for the IAR ICCAVR Compiler for the Family for how to modify the Linker Command File to fit the specific project. Figure 6. Selecting the XCL File 6

Writing the Source File When the Project options are properly configured, the next step is to write the source code. This application note uses a simple program that increments the PORTD to which the eight LEDs are attached. An 8-bit timer is used to generate a delay between incrementation, making it possible to see the LEDs flashing. To open a new source file, select File > New and then select Source/Text. In the new window that appears, type in the text below and save it as.c by selecting Save As in the File menu. Make sure to save the file in the C:\ directory. Program Listing for AT94K #include <ioat94k.h> /* Function Prototypes */ void initialization(void); void delay(void); /* Function Definitions */ void initialization(void) { DDRD = 0xFF; /* Set PORTD as Output */ TCCR0 = 0x05; /* Count SysClock/1024 */ } void delay(void) { while(!(tifr & 0x02)); /* Wait for TC0 Overflow Flag to Set */ TIFR = 0x02; /* Clearing Overflow Flag */ } /* Main Program */ void main(void) { initialization(); /* Initialize Peripherals */ } for(;;) /* Infinite Loop */ { PORTD++; /* Increment PORTD */ delay(); /* Short delay */ } The program is divided in three parts: initialization, delay and the main program. In the initialization part, PORTD is set as an output and Timer/Counter0 starts to count the system clock divided by 1024. In the delay subroutine, the controller waits for the Timer/Counter0 overflow flag to be set, then clears the flag and exits. In the main program, the content in PORTD is incremented and a delay is called to make the change on PORTD visible. 7

Including the Source File in the Project When the source code is written, it has to be included in the project. Selecting Files from the Project menu does this. The dialog box shown in Figure 7 appears. Navigate to the C:\ folder, select the file.c by clicking on it and select Add. Click Done to exit the dialog box. Figure 7. Selecting Source Files Compiling the Code To compile the code, select Project > Make or press the F9 key. If everything is done correctly, the code compiles and links with no errors and the debug[ubrof] code is placed in the file C:\\DEBUG\EXE\GETTING STARTED.DBG if the target is set to Debug. Alternatively, if the target is set to Release, the executable hex code is placed in the file C:\\RELEASE\EXE\GET- TING STARTED.A90. Loading the File into System Designer To simulate and run the code, the file must be loaded into System Designer. This application note describes how to load it into System Designer and the Starter Kit. When doing any sort of co-simulation, System Designer requires some sort of object file, depending on which compiler is being used, for the MCU simulation. The object file generated by the IAR Systems Embedded Workbench for AVR Compiler is the UBROF file, generated when the target is set to Debug. Whenever it is necessary to load the object file into AVR Studio, select C:\\DEBUG\EXE\GETTING STARTED.DBG. When generating the combined bitstream in System Designer and you are prompted for the software file, select the executable hex file, which is located at C:\\RELEASE\EXE\GETTING STARTED.A90. 8

Atmel Headquarters Corporate Headquarters 2325 Orchard Parkway San Jose, CA 95131 TEL (408) 441-0311 FAX (408) 487-2600 Europe Atmel SarL Route des Arsenaux 41 Casa Postale 80 CH-1705 Fribourg Switzerland TEL (41) 26-426-5555 FAX (41) 26-426-5500 Asia Atmel Asia, Ltd. Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimhatsui East Kowloon Hong Kong TEL (852) 2721-9778 FAX (852) 2722-1369 Japan Atmel Japan K.K. 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 Hotline 1-(408) 436-4119 Atmel e-mail fpslic@atmel.com FAQ Available from Website Atmel Operations Atmel Colorado Springs 1150 E. Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 TEL (719) 576-3300 FAX (719) 540-1759 Atmel Rousset Zone Industrielle 13106 Rousset Cedex France TEL (33) 4-4253-6000 FAX (33) 4-4253-6001 Atmel Smart Card ICs Scottish Enterprise Technology Park East Kilbride, Scotland G75 0QR TEL (44) 1355-803-000 FAX (44) 1355-242-743 Atmel Grenoble Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex France TEL (33) 4-7658-3000 FAX (33) 4-7658-3480 Fax-on-Demand North America: 1-(800) 292-8635 International: 1-(408) 441-0732 e-mail literature@atmel.com Web Site http://www.atmel.com BBS 1-(408) 436-4309 Atmel Corporation 2000. Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. Marks bearing and/or are registered trademarks and trademarks of Atmel Corporation. Terms and product names in this document may be trademarks of others. Printed on recycled paper. 1977A 11/00/xM