Atmel CAVR-4 Bedienungsanleitung
- Schauen Sie die Anleitung online durch oderladen Sie diese herunter
- 323 Seiten
- 3.17 mb
Zur Seite of
Ähnliche Gebrauchsanleitungen
-
Network Router
Atmel Diopsis 940HF
2 Seiten 0.69 mb -
Electronic Keyboard
Atmel 08PIA-DK
13 Seiten 0.12 mb -
Network Card
Atmel ATAVRAUTOEK1
5 Seiten 1.74 mb -
Computer Hardware
Atmel AT85DVK-07
21 Seiten 0.2 mb -
MP3 Player
Atmel AT83SND2C MP3
66 Seiten 0.75 mb -
Computer Hardware
Atmel AT91CAP7A-STK
2 Seiten 0.5 mb -
Projection Television
Atmel STK594
41 Seiten 4.82 mb -
Computer Drive
Atmel AT85RFD-07
10 Seiten 0.25 mb
Richtige Gebrauchsanleitung
Die Vorschriften verpflichten den Verkäufer zur Übertragung der Gebrauchsanleitung Atmel CAVR-4 an den Erwerber, zusammen mit der Ware. Eine fehlende Anleitung oder falsche Informationen, die dem Verbraucher übertragen werden, bilden eine Grundlage für eine Reklamation aufgrund Unstimmigkeit des Geräts mit dem Vertrag. Rechtsmäßig lässt man das Anfügen einer Gebrauchsanleitung in anderer Form als Papierform zu, was letztens sehr oft genutzt wird, indem man eine grafische oder elektronische Anleitung von Atmel CAVR-4, sowie Anleitungsvideos für Nutzer beifügt. Die Bedingung ist, dass ihre Form leserlich und verständlich ist.
Was ist eine Gebrauchsanleitung?
Das Wort kommt vom lateinischen „instructio”, d.h. ordnen. Demnach kann man in der Anleitung Atmel CAVR-4 die Beschreibung der Etappen der Vorgehensweisen finden. Das Ziel der Anleitung ist die Belehrung, Vereinfachung des Starts, der Nutzung des Geräts oder auch der Ausführung bestimmter Tätigkeiten. Die Anleitung ist eine Sammlung von Informationen über ein Gegenstand/eine Dienstleistung, ein Hinweis.
Leider widmen nicht viele Nutzer ihre Zeit der Gebrauchsanleitung Atmel CAVR-4. Eine gute Gebrauchsanleitung erlaubt nicht nur eine Reihe zusätzlicher Funktionen des gekauften Geräts kennenzulernen, sondern hilft dabei viele Fehler zu vermeiden.
Was sollte also eine ideale Gebrauchsanleitung beinhalten?
Die Gebrauchsanleitung Atmel CAVR-4 sollte vor allem folgendes enthalten:
- Informationen über technische Daten des Geräts Atmel CAVR-4
- Den Namen des Produzenten und das Produktionsjahr des Geräts Atmel CAVR-4
- Grundsätze der Bedienung, Regulierung und Wartung des Geräts Atmel CAVR-4
- Sicherheitszeichen und Zertifikate, die die Übereinstimmung mit entsprechenden Normen bestätigen
Warum lesen wir keine Gebrauchsanleitungen?
Der Grund dafür ist die fehlende Zeit und die Sicherheit, was die bestimmten Funktionen der gekauften Geräte angeht. Leider ist das Anschließen und Starten von Atmel CAVR-4 zu wenig. Eine Anleitung beinhaltet eine Reihe von Hinweisen bezüglich bestimmter Funktionen, Sicherheitsgrundsätze, Wartungsarten (sogar das, welche Mittel man benutzen sollte), eventueller Fehler von Atmel CAVR-4 und Lösungsarten für Probleme, die während der Nutzung auftreten könnten. Immerhin kann man in der Gebrauchsanleitung die Kontaktnummer zum Service Atmel finden, wenn die vorgeschlagenen Lösungen nicht wirksam sind. Aktuell erfreuen sich Anleitungen in Form von interessanten Animationen oder Videoanleitungen an Popularität, die den Nutzer besser ansprechen als eine Broschüre. Diese Art von Anleitung gibt garantiert, dass der Nutzer sich das ganze Video anschaut, ohne die spezifizierten und komplizierten technischen Beschreibungen von Atmel CAVR-4 zu überspringen, wie es bei der Papierform passiert.
Warum sollte man Gebrauchsanleitungen lesen?
In der Gebrauchsanleitung finden wir vor allem die Antwort über den Bau sowie die Möglichkeiten des Geräts Atmel CAVR-4, über die Nutzung bestimmter Accessoires und eine Reihe von Informationen, die erlauben, jegliche Funktionen und Bequemlichkeiten zu nutzen.
Nach dem gelungenen Kauf des Geräts, sollte man einige Zeit für das Kennenlernen jedes Teils der Anleitung von Atmel CAVR-4 widmen. Aktuell sind sie genau vorbereitet oder übersetzt, damit sie nicht nur verständlich für die Nutzer sind, aber auch ihre grundliegende Hilfs-Informations-Funktion erfüllen.
Inhaltsverzeichnis der Gebrauchsanleitungen
-
Seite 1
CA VR-4 A VR® IAR C/C++ Compiler Refer ence Guide for Atmel® Corporation’ s AV R ® Micr ocontr oller[...]
-
Seite 2
CA VR-4 COP YRIGHT NOTICE © Copyright 1996–20 05 IAR Syst ems. All rights reserved. No part of this document ma y be reproduced without the pr ior written consent of IAR Systems. The soft w are described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The inf[...]
-
Seite 3
CA VR-4 iii Brief contents T ables ............ ............ ......... ........... ........... ........... ........... ........... ........... ........... ........ xv Pr eface .... ........... ........... ........... ......... ........... ........... ............ ........... ........... ........... .. xix Part 1. Using the compiler ........... ....[...]
-
Seite 4
CA VR-4 iv A VR® IAR C/C++ Compiler Refer ence Guide Implementation-defined beha vior ........ ........... ........... ........... ........... ...... 255 IAR language extensions .................. ........... ......... ........... ........... ........... ...... 269 Diagnostics ...... ........... ........... ........... ........... ............ ...[...]
-
Seite 5
CA VR-4 v Contents T ables ............ ............ ......... ........... ........... ........... ........... ........... ........... ........... ........ xv Pr eface .... ........... ........... ........... ......... ........... ........... ............ ........... ........... ........... .. xix Who should read this guide .......... ........... .[...]
-
Seite 6
CA VR-4 vi A VR® IAR C/C++ Compiler Refer ence Guide Data storage .......... ........... ........... ........... ........... ............ ........... ........... ......... ..... 15 Introduction ............ ........... ........... ........... ......... ........... ............ ........... ...... 15 Storing data .. ........... ........... .........[...]
-
Seite 7
CA VR-4 Contents vii The return addres s stack ...... ........... ........... ........... ............ ........... ...... 43 The heap ........ ........... ........... ......... ........... ........... ........... ........... ......... 44 Located data .............. ........... ........... ........... ........... ............ ........... ...... 46 U[...]
-
Seite 8
CA VR-4 viii A VR® IAR C/C++ Compiler Refer ence Guide System startup and term ination ..... ............ ........ ............ ........... ...... 64 System startup .................. ........... ........... ........... ........... ........... ........... 65 System terminat ion .............. ........... ........... ........... ............ ......[...]
-
Seite 9
CA VR-4 Contents ix math.h ...... ........... ........... ........... ......... ............ ........... ........... ........... .... 83 stdio.h ...... ........... ........... ........... ............ ........... ........... ........... ........... .. 83 stdlib.h ..... ........... ........... ........... ............ ........... ........... .......[...]
-
Seite 10
CA VR-4 x A VR® IAR C/C++ Compiler Refer ence Guide Preserved ve rsus scratch regist ers ......... ........... ........... ............. ....... 101 Function call .. ........... ........... ........... ........... ........... ............ ........... .... 102 Function exit ............ ........... ........... ........... ........... ............ .[...]
-
Seite 11
CA VR-4 Contents xi Writing efficient code .. ........... ........... ........... ........... ............ ........... .... 130 Saving stack spa ce and RAM memory ......... ........... ............. ........... 131 Function prototypes ..... ............. ............ ............. ........... ........... ......... 131 Integer types and bit negation[...]
-
Seite 12
CA VR-4 xii A VR® IAR C/C++ Compiler Refer ence Guide Compiler options . ........... ........... ........... ......... ........... ........... ............ ........... ... 167 Setting command line options ............ ........... ........... ........... ........... 167 Specifying paramete rs ............ ........... ............ ........... ......[...]
-
Seite 13
CA VR-4 Contents xiii Library functions as intrin sic functions ............ ........... ........... ......... 248 IAR CLIB Library ......... ........... ......... ........... ........... ........... ........... ......... 248 Library definiti ons summary .. ........... ............ ........... ........... ........... .. 249 AVR–specific library f[...]
-
Seite 14
CA VR-4 xiv A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 15
CA VR-4 xv Ta b l e s 1: Typographic conventions used in this guide ..... ........... ................................. ...... xxii 2: Mapping of processor opti ons ........... .............. ........... ........... ............. ........... .......... 6 3: Summary of processor configuration .................. .............. ........... ...........[...]
-
Seite 16
CA VR-4 xvi A VR® IAR C/C++ Compiler Refer ence Guide 32: Floating-point t ypes ......... ............. ........... ........... ............ ........... ........... ............ 139 33: Function pointers ......... .............. ........... ........... ........... ........... ........... .............. ... 141 34: Data pointers ......... .........[...]
-
Seite 17
CA VR-4 Ta b l e s xvii 66: Nearfunc pointer size ................ ........... ........... ............. ........... ............ ........... ... 211 67: Tiny address ranges ........ ........... ........... ........... ............. ........... ............ ........... ... 213 68: Tinyflash addre ss ranges ............... ........... ........... ..[...]
-
Seite 18
CA VR-4 xviii A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 19
CA VR-4 xix Pr eface W elcome to the A VR® IAR C/C++ Compiler Ref erence Guide. Th e purpose of this guide is to pro vide you with detailed refer ence i nformation that can help you to use t he A VR IAR C/C++ Compiler to best suit your applicat ion requir ements. This guide also gives y o u suggestions on coding techniques so that you can de velop[...]
-
Seite 20
CA VR-4 xx What this guide contains A VR® IAR C/C++ Compiler Refer ence Guide What this guide contains Below is a brief outline and summar y of the chapters in this guide. P art 1. Using the compiler ● Getting started giv es the information you need to get started using the A VR IAR C/C++ Compiler for eff iciently dev eloping your application. ?[...]
-
Seite 21
CA VR-4 Preface xxi ● Library functions gives an introduction to the C or C++ library functions, and summarizes the header f iles. ● Implementation-def ined behavior describes how the AVR IAR C/C++ Compiler . handles the implementation-defined areas of the C language standard. ● IAR language e xtensions describes the IAR extensions to the ISO[...]
-
Seite 22
CA VR-4 xxii Document con ventions A VR® IAR C/C++ Compiler Refer ence Guide W e recommend that you visit the following websites: ● The Atmel® Corporation website, www.atmel.com , contains information and ne ws about the A VR microcontrollers. ● The IAR website, www.iar.com , holds application notes and other product information. ● Finally [...]
-
Seite 23
CA VR-4 1 P ar t 1. Using the compiler This part of the A VR® IAR C/C++ Compiler Refer ence Guide includes the follo wing chapters: ● Getting started ● Data storage ● Functions ● Placing code and data ● The DLIB runtime envir onment ● The CLIB runtime envir onment ● Assembler language interface ● Using C++ ● Efficient coding for [...]
-
Seite 24
CA VR-4 2[...]
-
Seite 25
CA VR-4 Part 1. Using the compiler 3 Getting star ted This chapter giv es the information you need to get star ted using the A VR IAR C/C++ Compiler for efficiently de veloping y our application. First you wi ll get an overview of the supported programming languages, follo wed by a description of the steps inv olved f or compiling and linking an ap[...]
-
Seite 26
CA VR-4 4 Building applications—an ov er view A VR® IAR C/C++ Compiler Refer ence Guide For more information about the Embedded C++ language and IAR Extended Embedded C++, see the c hapter Using C++ . Building applications—an o verview A typical application is built from a number of source files and libraries. The source f iles can be written [...]
-
Seite 27
CA VR-4 Part 1. Using the compiler Getting started 5 In this example, myfile . r90 and myfile2.r90 are object files, lnkm128s.xcl is the linker comm and file, and cl3s-ec.r90 is th e runtime library . The option -s spe cifies the label where the appli c ation starts. The option -o specif ies the name of the output file, and the option -F can be use[...]
-
Seite 28
CA VR-4 6 Basic settings for project configuration A VR® IAR C/C++ Compiler Refer ence Guide Both options set up default beha vior—i mplicit assumptions—but note that the --cpu option is more precise because it contains more information about the intended tar get than the mo re generic -v option. The --cpu option kno ws, for example, ho w much[...]
-
Seite 29
CA VR-4 Part 1. Using the compiler Getting started 7 --cpu=at43usb320a -v3 A T43USB320A --cpu=at43usb325 -v3 A T43USB325 --cpu=at43usb326 -v3 A T43USB326 --cpu=at43usb351m -v3 A T43USB351m --cpu=at43usb353m -v3 A T43USB353m --cpu=at43usb355 -v3 A T43USB355 --cpu=at94k -v3 FpSLic --cpu=at86rf401 -v0 A T86RF40 1 --cpu=can128 -v3 A T90CAN128 --cpu=m8 [...]
-
Seite 30
CA VR-4 8 Basic settings for project configuration A VR® IAR C/C++ Compiler Refer ence Guide Summar y of pr ocessor configuration The follo wing table summarizes t he memory characterist ics for each -v option: --cpu=m329 -v3 A Tmega329 --cpu=m3290 -v3 A Tmega3290 --cpu=m406 -v3 A Tmega406 --cpu=m645 -v3 A Tmega645 --cpu=m6450 -v3 A Tmega6450 --cp[...]
-
Seite 31
CA VR-4 Part 1. Using the compiler Getting started 9 Note: ● *) When using the -v5 or the -v6 option, it is possible, for indi vidual functions, to ov erride the _ _farfunc attribute and instead use the _ _nearfunc attribute ● Pointers with function memory a ttributes ha ve restrictions in implic it and explicit casts between pointers and be tw[...]
-
Seite 32
CA VR-4 10 Basic settings for project configuration A VR® IAR C/C++ Compiler Refer ence Guide Y our program may use only one memory model at a time, and the same model must be used by all user modules and all library modules. Summary of memory models The follo wing table summarizes the characteristics for each memory model: For more details about [...]
-
Seite 33
CA VR-4 Part 1. Using the compiler Getting started 11 RUNTIME EN V IRONMENT T o create the required runtime en vironment you should choose a runtime library and set library options. Y ou may also need to ove rride certain library modules with your own customized versions. There are tw o different sets of runtime libr aries provided: ● The IAR DLI[...]
-
Seite 34
CA VR-4 12 Special support for embedded systems A VR® IAR C/C++ Compiler Refer ence Guide Choosing a runtime librar y from the command line Use the follow ing command line options to specify the library and the dependenc y files: For a list of all prebuilt library object f ile s for the IAR DLIB Library , see T able 15, Pr ebuilt libraries , page [...]
-
Seite 35
CA VR-4 Part 1. Using the compiler Getting started 13 The command line option - e makes the e xtended keywords a v ailable, and reserves them so that they cannot be used as variable names. See, -e , page 179 for additional information. For detailed descriptions of the extended k eywords, see the chapter Extended keywor ds . T o read about special f[...]
-
Seite 36
CA VR-4 14 Special support for embedded systems A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 37
CA VR-4 Part 1. Using the compiler 15 Data stora g e This chapter gives a brief introduction to the memor y lay out of the A VR microcontr oller and the fundamental wa ys data can be stor ed in memor y: on the stack, in st atic (global) m emor y , or in heap memor y . For efficient memor y usage, A VR IAR C/C++ Compiler pro vides a set of memor y m[...]
-
Seite 38
CA VR-4 16 Introduction A VR® IAR C/C++ Compiler Refer ence Guide ● On the heap. Once memory has been allo cated on the heap, it remains va lid until it is explicitly released back to the system b y the application. This type of memory is useful when the number of objects is not known until the applic atio n executes. Note that there are potenti[...]
-
Seite 39
CA VR-4 Part 1. Using the compiler Data storage 17 Note that the location of the pointer variable p is not af fected by the keyw ord. In the following e xample, howe ver , the pointer variable p2 is placed in far memo ry . Like p , p2 points to a character in EEPR OM memory . char _ _eeprom * _ _far p2; T ype definitions Storage can also be specif [...]
-
Seite 40
CA VR-4 18 Memory types and memor y attributes A VR® IAR C/C++ Compiler Refer ence Guide Y our project can only use one memory model at a time , and the sa me model must be used by all user modules and all library modules. If you do not specify a memory mo del option, the c ompiler will use the T iny m emory model for all processor options, except[...]
-
Seite 41
CA VR-4 Part 1. Using the compiler Data storage 19 By selecting a memory model , you ha ve selected a default memory type that your application will us e. Ho wever , it is possible to sp ecify—for individual variables or pointers—different memory types. This makes it possible to create an application that can contain a lar ge amount of data, an[...]
-
Seite 42
CA VR-4 20 Memory types and memor y attributes A VR® IAR C/C++ Compiler Refer ence Guide The ke ywords are only av ailable if language extensions are enabled in the A VR IAR C/C++ Compiler . In IAR Embedded W orkbench, language extensions are enabled by def ault. Use the -e compiler option to enable language extensions. See -e , page 179 for addit[...]
-
Seite 43
CA VR-4 Part 1. Using the compiler Data storage 21 Differ ences between pointer types A pointer must contain information needed to specify a memory location of a certain memory type. This m eans that the pointer sizes are di fferent for dif ferent memory types. For informat ion about the sizes of the different pointer types, see P ointer t ypes , p[...]
-
Seite 44
CA VR-4 22 C++ and memory types A VR® IAR C/C++ Compiler Refer ence Guide In short: C++ and memor y types A C++ class object is placed in one memory type, in the same way as for normal C structures. Ho wev er , the class members that are considered to be part of the object are the non-static member v ariables. The static member v ariables can be p[...]
-
Seite 45
CA VR-4 Part 1. Using the compiler Data storage 23 Example In the example belo w , an object, named delta , of the type MyClass is defined in data16 memory . The class contains a static member variable that is stored in data20 memory . // The class declaration (placed in a header file): class MyClass { public: int alpha; int beta; _ _eeprom static [...]
-
Seite 46
CA VR-4 24 The stack and auto variables A VR® IAR C/C++ Compiler Refer ence Guide The stack is a fix ed block of memory , divide d into two parts. The first part contains allocated memory used b y the function that called the current fu nction, and the function that called it, etc. The sec ond part contains free memory that can be allocated. The b[...]
-
Seite 47
CA VR-4 Part 1. Using the compiler Data storage 25 Dynamic memor y on the heap Memory for objects a llocated on the heap wil l live until the objects are explicitly released. This type of memory storage is ve ry useful for applications where the amount of data is not kno wn until runtime. In C, memory is allocated usi ng the standard library functi[...]
-
Seite 48
CA VR-4 26 Dynamic memory on the heap A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 49
CA VR-4 Part 1. Using the compiler 27 Functions This chapter contains information abou t functions. First, y ou get a brief ov er view of mechanisms for contr olling functions, as w ell as information about memor y type attributes for function st orage . Then, the special function types interrupt and monitor are described, including how to declare [...]
-
Seite 50
CA VR-4 28 Function stor age A VR® IAR C/C++ Compiler Refer ence Guide Syntax The extended ke ywords are specified be fore the return type, for example: _ _interrupt void alpha(void); The keyw ords that are type attrib utes must be specified both when they are def ined and in the declaration. Object attributes only ha ve to be sp ecified when they[...]
-
Seite 51
CA VR-4 Part 1. Using the compiler Functions 29 Special function types This section describes the sp ecial function types interrupt and monitor . The A VR IAR C/C++ Compiler allo ws an application to take ful l advantage of these A VR features, without forcing you to implemen t anything in as sembler language. INTERRUPT FUNCTIONS In embedded system[...]
-
Seite 52
CA VR-4 30 Special function types A VR® IAR C/C++ Compiler Refer ence Guide MONITOR FUNCTIONS A monitor function causes interrupts to be disabled during ex ecution of the function. At function entry , the status register is sav ed and interrupts are disabled. At function exit, the original status register is restored, and th ereby the interrupt st[...]
-
Seite 53
CA VR-4 Part 1. Using the compiler Functions 31 The following is an example of a program fragment that uses the semaphore: void my_program(void) { if (get_lock()) { /* ... Do something ... */ /* When done, release the lock. */ release_lock(); } } The drawback using this method is that in terrupts are disabled fo r the entire moni tor function. Exam[...]
-
Seite 54
CA VR-4 32 Special function types A VR® IAR C/C++ Compiler Refer ence Guide void f() { static long next_stop = 100; extern void do_stuff(); long tick; /* A critical block */ { Mutex m; /* Read volatile variable 'tick_count' in a safe way and put the value in a local variable */ tick = tick_count; } if (tick >= next_stop) { next_stop +[...]
-
Seite 55
CA VR-4 Part 1. Using the compiler 33 Placing code and data This chapter intr oduces the concept of segments, and describes the differ ent segment groups and segment types. It al so describes how they corr espond to the memor y and function types, and how the y interact with the runtime envir onment. The methods for placing segments in memor y , wh[...]
-
Seite 56
CA VR-4 34 Placing segments in memory A VR® IAR C/C++ Compiler Refer ence Guide For detail ed information about i ndividual se gments, see the chapter Se gment refer ence in P art 2. Compiler refer ence . Segment memor y type XLINK assigns a se gment memory type to each of the segments. In some c ases, the individual se gments may hav e the same n[...]
-
Seite 57
CA VR-4 Part 1. Using the compiler Placing code and data 35 CUSTOMIZING THE LINK ER COMMAND FILE The only change you will normally ha ve to ma ke to the supplied linker command f ile is to customize it so it reflects the tar get system memory map. As an exampl e, we can assume that the targ et system has the follow ing memory layout: The flash memo[...]
-
Seite 58
CA VR-4 36 Placing segments in memory A VR® IAR C/C++ Compiler Refer ence Guide See the IAR Linker and Libr ary T ools Reference Guide for more details. Using the -Z command for sequential placement Use the -Z command when you need to keep a segment in one consecutive chunk, when you need to preserv e the order of segment parts in a se gment, or ,[...]
-
Seite 59
CA VR-4 Part 1. Using the compiler Placing code and data 37 Note: Copy initialization segments— BASENAME _I and B ASENAME _ID —must be placed using -Z. Data segments This section contains descriptions of the segm ents used for storing the dif ferent types of data—static, stack, heap, and located. In moste cases thes e segments are located in [...]
-
Seite 60
CA VR-4 38 Data segments A VR® IAR C/C++ Compiler Refer ence Guide would yield the se gment base name NEAR . The suf fix indicates what type of de clared data the segment holds. The follo wing table summarizes the dif ferent suf fixe s, which XLINK segment memory type they are, and which categor y of declared data they denote: For information abou[...]
-
Seite 61
CA VR-4 Part 1. Using the compiler Placing code and data 39 Initialized data In ISO/ANSI C all static v ariables—v ariables that are allocated at a f ixed memory address—ha ve to be initialized b y the run-time system to a known v alue. This v alue is either an e xplicit v alue assigned to the v ariable , or if no value is gi ven, it is cleared[...]
-
Seite 62
CA VR-4 40 Data segments A VR® IAR C/C++ Compiler Refer ence Guide 3 Finally , global C++ objects ar e constructed, if any . Initialization of local aggr egates at function in vocation Initialized aggre gate auto variable s—struct, union, and array variab les local to a function—ha ve the initial v alues in blocks of memory As an auto v ariabl[...]
-
Seite 63
CA VR-4 Part 1. Using the compiler Placing code and data 41 address of a constant _ _flash object and use it as a default pointer object, th e compiler will issue an error . If you make an explicit ca st o f the object to a default pointer object, the error message di sappears, instead t here will be problem s at run-time as the cast cannot copy th[...]
-
Seite 64
CA VR-4 42 Data segments A VR® IAR C/C++ Compiler Refer ence Guide If externa l SRAM is av ailable it is possible t o place the stack there. Howe ver , the extern al memory is slo wer than the internal stack so mo ving it to external memory will decrease the performa nce. Allocating a memory area for the stack is done differently when you use the [...]
-
Seite 65
CA VR-4 Part 1. Using the compiler Placing code and data 43 THE RETURN AD DRESS STACK The return address stack is used fo r storing the return address when a CALL , RCALL , ICALL , or EICALL instruction is e xecuted. Each ca ll will use two or three b ytes of return address stack. An interrupt will also place a ret urn addr ess on this stack. T o d[...]
-
Seite 66
CA VR-4 44 Data segments A VR® IAR C/C++ Compiler Refer ence Guide THE HEAP The heap contains dynamic data al located by use of the C function malloc (or one of its relati ves) or the C++ operator new . If your application uses dyna mic memory allocati on, you should be familiar with the following: ● Linker segment used for the heap, which dif f[...]
-
Seite 67
CA VR-4 Part 1. Using the compiler Placing code and data 45 Heap siz e allocation in IAR Embedded W orkbench Select Project>Options . In the General Options category , click the Heap configuration pag e. Add the required heap size in the appropriate text box. Heap size allocation from the command line The size of t he heap segments are defined i[...]
-
Seite 68
CA VR-4 46 Code segments A VR® IAR C/C++ Compiler Refer ence Guide LOCATED DATA A variab le that has been e xplicitly placed at an address, for example by using the compiler @ syntax, will be placed in either the SEGMENT _AC or the SEGMENT _AN segment. The former is used for constant -initializ ed data, and the latter for items declared as _ _no_i[...]
-
Seite 69
CA VR-4 Part 1. Using the compiler Placing code and data 47 In the link er command file it can look like this: -Z(CODE)CODE=0-1FFF USER -DEFINED SEGMENTS If you create your o wn segments—see Contr olling data and function placement , page 47—these must also be defined in the link er command file using the -Z or -P se gment control directi ves. [...]
-
Seite 70
CA VR-4 48 Efficient usage of segments and memory A VR® IAR C/C++ Compiler Refer ence Guide Note: Take care whe n explicitly placing a variable or functio n in a prede fined segment other than the one used by default. This is possible and useful in some situ ations, but incorrect placement ca n result in anything from error messages during compila[...]
-
Seite 71
CA VR-4 Part 1. Using the compiler Placing code and data 49 Example _ _no_init int alpha @ "MYSEGMENT"; /* OK */ #pragma location="MYSEGMENT" const int beta=5; /* OK */ const int gamma @ "MYSEGMENT" = 3; /* OK */ int delta @ "MYSEGMENT"; /* Error, neither */ /* "_ _no_init" nor "const" */ [...]
-
Seite 72
CA VR-4 50 V erifying the linked r esult of c ode and data placement A VR® IAR C/C++ Compiler Refer ence Guide A typical situation wher e this can be useful is if you ne ed to optimize accesses to code and data that is frequently used, and place it in a dif ferent physical memory . T o use your own seg ments, use the #pragma location directive, or[...]
-
Seite 73
CA VR-4 Part 1. Using the compiler Placing code and data 51 Normally , XLINK will not genera te an output file if ther e are any errors, such a s range errors, during the linking process. Use the option Always generate output in IAR Embedded W orkbench, or the option -B on the command line, to generate an output file ev en if a range error was enco[...]
-
Seite 74
CA VR-4 52 V erifying the linked r esult of c ode and data placement A VR® IAR C/C++ Compiler Refer ence Guide The IAR P ostlink utility Y ou can also use the IAR Postlink utility , deliv ered with the A VR IAR C/C++ Compiler to generate multiple output fi les. This applicat ion takes as input an object file (of the XLINK simple format) and extrac[...]
-
Seite 75
CA VR-4 Part 1. Using the compiler 53 The DLIB runtime en vir onment This chapter descr ibes the runtime en vironment in which an appl ication ex ecutes. In par ticular , the cha pter co vers the DLIB runtime l ibrar y and how you can modify it—setting options, ov erriding default library modules, or building y our own lib rar y—to optimize it [...]
-
Seite 76
CA VR-4 54 Introductio n to the runtime environment A VR® IAR C/C++ Compiler Refer ence Guide The runtime library is deliv ered both as prebuilt libraries and as source files, and you can find them in the product subd irectories avrlib and avrsrc , respecti vely . The runtime en vironment also consists of a part with specific support for the tar[...]
-
Seite 77
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 55 SITUATIONS THAT REQUIRE LIBRAR Y BUILDING Building a customized librar y is comple x. Y ou should therefore carefully consider whether it is really necessa ry . Y ou must build your own library when: ● There is no prebuilt library for the require d combination of compiler option[...]
-
Seite 78
CA VR-4 56 Using a prebuilt library A VR® IAR C/C++ Compiler Refer ence Guide DEBUG SUPPOR T IN THE RUNTIME LIBRAR Y Y ou can make the library provide different le vels of deb ugging support—basic, runtime, and I/O debugging. The follo wing table describes the different le vels of deb ugging support: If you build your application project with th[...]
-
Seite 79
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 57 ● Small flash memory option ( --64k_flash ) ● 64-bit doubles option ( --64bit_doubles ) ● Library configuration—Normal or Full. For the A VR IAR C/C++ Compiler and the Normal l ibrary configuration, there are preb uilt runtime libraries for all combinatio ns of th ese opti[...]
-
Seite 80
CA VR-4 58 Using a prebuilt library A VR® IAR C/C++ Compiler Refer ence Guide On the command line, you must specify the follo wing items: ● Specify which library object file to use on t he XLINK command line, for in stance: dlavr-3s-ec-64-f.r90 ● Specify the inclu de paths for the compiler and assembler: -I avrinc ● Specify the library conf[...]
-
Seite 81
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 59 Choosing fo rmatters for printf and scanf T o ov erride the default formatter for all the printf- and scanf -related functio ns, except for wprintf and wscanf v ariants, you simply set the appropriate library options. This section describes the dif feren t options av ailable. Note[...]
-
Seite 82
CA VR-4 60 Choosing formatters fo r printf and scanf A VR® IAR C/C++ Compiler Refer ence Guide For information about how to fine-tune the formatting capabilities even further, see Configuration symbols for printf and scan f , page 69 . Specifying print formatter in IAR Embedded W orkbench T o specify the printf formatter in IAR Embe dded W orkbenc[...]
-
Seite 83
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 61 For information about how to fine-tune the formatting capabilities even further, see Configuration symbols for printf and scan f , page 69 . Specifying scanf formatter in IAR Embedded W orkbench T o specify the scanf formatter in IAR Embe dded W orkbench, ch oose Project>Option[...]
-
Seite 84
CA VR-4 62 Building and using a customized librar y A VR® IAR C/C++ Compiler Refer ence Guide Over riding librar y modules from the command line This procedure is applicable to any source file in the library , which means library_module .c in this example can be any module in the library . 1 Copy the appropriate library_module .c to your project d[...]
-
Seite 85
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 63 SETTING UP A LIBRAR Y PROJECT IAR Embedded W orkbench provides a library project templa te whic h can be used for customizing the runtime en vir onment configuration. This library template has full library conf iguration, see T able 13, Library configur ations , page 55. In IAR Em[...]
-
Seite 86
CA VR-4 64 System startup and termination A VR® IAR C/C++ Compiler Refer ence Guide System star tup and termination This section describes the runtime en vironment actions performs during startup and termination of applications. The follo wing figur e gives a graphical ov erview of the startup and exit sequences: F igure 1: Startup and exit sequen[...]
-
Seite 87
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 65 SYSTEM STAR TUP When an applicati on is initialized , a number of steps are performed: ● When the cpu is reset it will jum p to the program entry label _ _program_start in the system startup code. ● Enables the external data and address buses if needed ● Initializes the stac[...]
-
Seite 88
CA VR-4 66 Customizing system init ialization A VR® IAR C/C++ Compiler Refer ence Guide C-SPY interface to system termination If your project is link ed with the XLINK options With runtime control modules or With I/O emulation modules , the normal _ _exit and abort functions are replaced with special ones. C-SPY will then recogn iz e when those fu[...]
-
Seite 89
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 67 MODIFYING THE FILE CSTA RTUP.S90 As noted earlier , you s hould not modify the file cstartup.s90 if a customi zed version of _ _low_level_init is enough for your needs. Ho wever , if you do need to modify the fi le cstartup.s90 , we recommend that you follow the general procedure [...]
-
Seite 90
CA VR-4 68 Standard str eams for input and output A VR® IAR C/C++ Compiler Refer ence Guide { int nChars = 0; /* Check for stdout and stderr (only necessary if file descriptors are enabled.) */ if (Handle != 1 && Handle != 2) { return -1; } for (/*Empty */; Bufsize > 0; --Bufsize) { LCD_IO = * Buf++; ++nChars; } return nChars; } The cod[...]
-
Seite 91
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 69 Configuration symbols for printf and scanf When you set up your application p roject, you typically need to consider what printf and scanf formatting capabilities your application requires, see Choosing formatters for printf and scanf , page 59. If the provided for matters do not [...]
-
Seite 92
CA VR-4 70 File input and output A VR® IAR C/C++ Compiler Refer ence Guide CUSTOMIZING FORMATTING CA PABILITIES T o customize the formatti ng capabilities, yo u need to set up a library project, see Building and using a customized library , page 62. Define the configuration symbols according to your appl ication requirements. File input and output[...]
-
Seite 93
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 71 Locale Locale is a part of the C language that allows language- and country-specific settings for a number of areas, such as currency symbol s, date and time, a nd multibyte encoding. Depending on what runtime library you are us ing you get dif ferent lev el of locale support. Ho [...]
-
Seite 94
CA VR-4 72 Locale A VR® IAR C/C++ Compiler Refer ence Guide Note: If you use multibyte characters in your C or assembler source code, make sure that you select the correct locale symbol (the local host locale). Building a librar y without suppor t for locale interface The locale inte rface is not incl uded if the configuration symbol _DLIB_FULL_LO[...]
-
Seite 95
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 73 En vir onment interaction According to the C standard, your applicati on can interact with the en vironment using the functions getenv and system . Note: The putenv function is not required by the standard, and the library does not provide an implementation of it. The getenv funct[...]
-
Seite 96
CA VR-4 74 Time A VR® IAR C/C++ Compiler Refer ence Guide This does not require that you rebuild the library . Y ou can fi nd source templates in the fil es Signal.c and Raise.c in the avrsrclib directory . For information about ove rriding default library modules, see Overriding library modules , page 61. If you decide to reb uild the library ,[...]
-
Seite 97
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 75 Asser t If you hav e linked your application with support for runtime debugging, C-SPY will be notified about failed asserts. If this is not the behavior you require, you must ad d the source f ile xReportAssert.c to your application proj ect. Altern atively , you can rebuild the [...]
-
Seite 98
CA VR-4 76 C-SPY Debugger runtime in terface A VR® IAR C/C++ Compiler Refer ence Guide C-SPY Debugger runtime interface To include suppo rt for runtime and I/O debugging, yo u must link you r application with the XLINK optio ns With runtime control modules or With I/O emulation modules , see Debug support in the runtime l ibrary , page 56. In this[...]
-
Seite 99
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 77 The mechanism used for implementing this feature w orks as follows. The deb ugger will detect the presence of the function _ _DebugBreak , which will be part of the application if you hav e linked it with the XLINK options for C-SPY runtime inte rface. In this case, the debugger w[...]
-
Seite 100
CA VR-4 78 Checking module consistency A VR® IAR C/C++ Compiler Refer ence Guide Example In the following table, the obj ect f iles could (but do not hav e to) define the two runtime attribu tes color and taste . In thi s case, file1 cannot be linked with any of the other files, sinc e the runtime attribute color doe s not ma tch. Als o, file4 and[...]
-
Seite 101
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 79 PREDEFI NED RUNTIME ATTRIBUTES The table below shows the predefined runtime model attributes that are av ai lable for the A VR IAR C/C++ Com piler . These can be include d in assembler code or in mixed C or C++ and assembler code. The easiest way to f ind the proper settings of th[...]
-
Seite 102
CA VR-4 80 Checking module consistency A VR® IAR C/C++ Compiler Refer ence Guide Examples For an example of using th e runtim e model attribute _ _rt_version for checking module consistency on used calling con vention, see Hints for using the new calling con vention , page 100. The following assembler source code provides a function, part2 , that [...]
-
Seite 103
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 81 Implementation of system star tup code This section presents some ge neral techniques used in the system startup code, including background information that might be useful if you need to modify it. Note: Do not modify the file cstartup.s90 unless required by your application. You[...]
-
Seite 104
CA VR-4 82 Added C functionality A VR® IAR C/C++ Compiler Refer ence Guide This lets the system startup code specify c ode in subsequent se gm ent parts and modules that are designed so that some of the part s may not be included by XLINK. The code simply falls through to the ne xt piece of code not discarded b y the linker . The following example[...]
-
Seite 105
CA VR-4 Part 1. Using the compiler The DLIB runtime en vironmen t 83 ● stdlib.h STDINT.H This include f ile provide s integer charact eristics. STDBOOL.H This include file makes the bool t ype av ai lable if the Allow IAR extensions ( -e ) option is used. MATH.H In math.h all functions e xist in a float v ariant and a long double var i a nt , s u[...]
-
Seite 106
CA VR-4 84 Added C functionality A VR® IAR C/C++ Compiler Refer ence Guide PRINTF, SCANF AND STRTOD The functions printf , scanf and strtod have added fun ctionality from the C99 standard. For reference info rmation about these functions, see the library reference av ailable from the Hel p menu.[...]
-
Seite 107
CA VR-4 Part1. Using the compiler 85 The CLIB runtime en vir onment This chapter describes the runtime en vironment in which an a pplication ex ecutes. In particular , it covers the CLIB runtime librar y and how you can optimize it f or your application. The standard librar y uses a small set of low-leve l in put and output routines for character -[...]
-
Seite 108
CA VR-4 86 Runtime envir onment A VR® IAR C/C++ Compiler Refer ence Guide ● Small flash memory option ( --64k_flash ) ● 64-bit doubles option ( --64bit_doubles ). For the A VR IA R C/C++ Compiler, this means there are prebuilt runtime librarie s for different combination of th ese options. The follo wing table shows the names of the libraries [...]
-
Seite 109
CA VR-4 Part1. Using the compiler The CLIB runtime en vironmen t 87 Input and output Y ou can customize: ● The functions rela ted to character -based I/O ● The formatters used by printf / sprintf and scanf / sscanf . CHARACTER -BASED I/O The functions putchar and getchar are the f undamental f unctions through which C performs all character -ba[...]
-
Seite 110
CA VR-4 88 Input and outp ut A VR® IAR C/C++ Compiler Refer ence Guide _medium_write The _medium_write formatter has the same functions as _formatted_write , except that floating-point numbers are not supported. Any attempt to use a %f , %g , %G , %e , or %E specifier will produce a runtime error: FLOATS? wrong formatter installed! _medium_write i[...]
-
Seite 111
CA VR-4 Part1. Using the compiler The CLIB runtime en vironmen t 89 F O RMATTERS US ED BY SCANF AND SSC ANF Similar t o the printf and sprintf functions, scanf and sscanf use a common formatter, called _formatted_read . The full v ersion of _formatted_read is very large, and provides facilities that are not required in many embedded applications. T[...]
-
Seite 112
CA VR-4 90 Over riding default librar y modules A VR® IAR C/C++ Compiler Refer ence Guide ● Static v ariables are initialized e xcept for _ _no_init and _ _eeprom declare d vari ables; this includes clearing zero-initializ ed memory and copying the R OM image of the RAM memory of the remaini ng initialized v ariables ● The main function is cal[...]
-
Seite 113
CA VR-4 Part1. Using the compiler The CLIB runtime en vironmen t 91 C-SPY runtime interface The low-le vel deb ugger interface is used for communication betw een the application being debugged and the deb ugger itself. The interface is simple : C-SPY will place breakpoints on certain assemble r labels in the application. When code located at the sp[...]
-
Seite 114
CA VR-4 92 Checking module consistency A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 115
CA VR-4 Part1. Using the compiler 93 Assembler langua ge interface When you dev elop an application for an embedded system, ther e may be situations wher e you will find it necessar y to write parts of the code in assembler , for examp le, when using me chanisms in the A VR micr ocontroller that requir e precise timing and special instruction seque[...]
-
Seite 116
CA VR-4 94 Mixing C and assembler A VR® IAR C/C++ Compiler Refer ence Guide The advantage of an intrinsic function compar ed to using inline assembler is that the compiler has all ne cessary in formation to interface the se quence properly with register allocation and v ariables. The compiler also knows ho w to optimize functions with such sequenc[...]
-
Seite 117
CA VR-4 Part1. Using the compiler Assembler language interface 95 INLINE ASSEMB LER It is possible to insert assembler code dire ctly into a C or C++ function. The asm keyw ord assembles and inserts the supplied assembler statemen t, or statements, in-line. The following example sho ws how to use inline assembler to insert assembler instructions di[...]
-
Seite 118
CA VR-4 96 Calling assembler routines fr om C A VR® IAR C/C++ Compiler Refer ence Guide Calling assembler r outines fr om C An assembler routine that is to be called from C must: ● Conform to the calling con vention ● Have a PUBLIC entry-point label ● Be declared as external before any cal l, to al low type ch ecking and op tional promotion [...]
-
Seite 119
CA VR-4 Part1. Using the compiler Assembler language interface 97 Note: In this example we use a low optimizat io n level when compiling the code to show local and global variab le access. If a higher level of optimization is used, the required references to loca l variables could be removed during the optimization. The actual function declaration [...]
-
Seite 120
CA VR-4 98 Calling assembler routines fr om C++ A VR® IAR C/C++ Compiler Refer ence Guide Calling assembler r outines fr om C++ The C calling con vention does not apply to C++ functions. Most importantly , a function name is not suff icient to iden tify a C++ f unction. The scope and the typ e of the function are also required to guarant ee type-s[...]
-
Seite 121
CA VR-4 Part1. Using the compiler Assembler language interface 99 Calling con vention A calling con vention is the way a function in a program calls another function. The compiler handles this a utomatically , but, if a f unction is written in assembler language, you must know where and how its parameters ca n be found, how to return to the program[...]
-
Seite 122
CA VR-4 100 Calling convention A VR® IAR C/C++ Compiler Refer ence Guide For detail s about the --version1_calls option and the _ _version_1 attribute, see --version1_calls , page 199 and _ _version_1 , page 214, respecti vely . Hints for using the new calling con vention The ne w calling con vention is ver y complex, and therefore not recommended[...]
-
Seite 123
CA VR-4 Part1. Using the compiler Assembler language interface 101 It is often practical to share header f ile s between C and C++. The f ollowing is an example of a declarati on that declares a function with C link age in both C and C++: #ifdef _ _cplusplus extern "C" { #endif int f(int); #ifdef _ _cplusplus } #endif PRES ER VED VE RSUS [...]
-
Seite 124
CA VR-4 102 Calling convention A VR® IAR C/C++ Compiler Refer ence Guide Special registers For some registers th ere are certain prerequisites that you must consider: ● The stack pointer—register Y —must at all times point to the last element on the stack. In the e ventuality of an interrupt, e verything belo w the point that the stack point[...]
-
Seite 125
CA VR-4 Part1. Using the compiler Assembler language interface 103 Register assignment using the old calling con vention In the old calling convention , the two left-most parameters are passed in registers if they are scalar and up to 32 bits in size. The follo wing table shows some of the possible combinations: * Where b denotes an 8-bit data type[...]
-
Seite 126
CA VR-4 104 Calling convention A VR® IAR C/C++ Compiler Refer ence Guide This would result in a be ing allocated to R16 (first f it), b to R19:R18 (alignment), c to R23:R22:R21:R20 (f irst fit), and d to R17 (first f it). A third ex ample: void baz(char a, char _ _far * b, int c, int d) This would gi ve, a being allocated to R16 , b to R22:R21:R20[...]
-
Seite 127
CA VR-4 Part1. Using the compiler Assembler language interface 105 Hidden parameters In addition to the parameters visib le in a function declarat ion and definition, there can be hidden parameters: ● A function returning stru ctures or unions lar ger than four bytes gets an e xtra hidden parameter , which is a default poi nter—depending on the[...]
-
Seite 128
CA VR-4 106 Calling convention A VR® IAR C/C++ Compiler Refer ence Guide Registers used for returning values For both calling conv entions, the registers availa ble for returning values are R16–R19 . Note that the size of a returned point er depends on the memory model in use; appropriate registers are used accordingly . Stack handling Normally [...]
-
Seite 129
CA VR-4 Part1. Using the compiler Assembler language interface 107 Monitor functions A monitor function causes interrupts to be disabled during ex ecution of the function. At function entry , the status register SREG is saved and global interrupts are disabled. At function exit, the global interrupt en able bit (I) is restored in the SREG register [...]
-
Seite 130
CA VR-4 108 Call frame information A VR® IAR C/C++ Compiler Refer ence Guide It is the responsibility of the calling function to allocate a memory locat ion for the return value and pass a pointer to it as a hidden f irst parameter . The pointer to the location where the return value should be stored is passed in the f irst suitable register/re gi[...]
-
Seite 131
CA VR-4 Part 1. Using the compiler 109 Using C++ IAR Systems supports two le vels of the C++ language: The i ndustr y-standard Embedded C++ and IAR Extended Em bedded C++. They ar e described in this chapter . Ov er vie w Embedded C++ is a subset of the C++ pr ogramming language which is intended for embedded systems programming. It w as defi ned b[...]
-
Seite 132
CA VR-4 110 Overview A VR® IAR C/C++ Compiler Refer ence Guide ● New cast syntax (the operators dynamic_cast , static_cast , reinterpret_cast , and const_cast ) ● Namespaces ● Mutable attrib ute. The exclusion of these language features ma kes the runtime library significantly more eff icient. The Embedded C+ + library furtherm ore dif fers [...]
-
Seite 133
CA VR-4 Part 1. Using the compiler Using C++ 111 T o set the equi va lent option in IAR Embedded W ork bench, select Project>Options>C/C ++ Compiler>Language . F eature descriptions When writing C++ source code for the IAR C/C++ Compiler , there are some benef its and some possible quirks that you need to be a ware of when mi xing C++ feat[...]
-
Seite 134
CA VR-4 112 Feature description s A VR® IAR C/C++ Compiler Refer ence Guide Example class B { public: void f(); int i; }; Class me mor y T o compensate for this limitation, a class can be associated with a class memory type . The class m emory type change s: ● the this pointer type in all member functions, constructors, and destructors in to a p[...]
-
Seite 135
CA VR-4 Part 1. Using the compiler Using C++ 113 Note: Whenever a cla ss type associated with a class memo ry type, like C , must be declared, the class memo ry type must be mentioned as well: class _ _far C; Also note that class types associ ated with different class memories are not compatib le types. There is a bu ilt-in operator that returns th[...]
-
Seite 136
CA VR-4 114 Feature description s A VR® IAR C/C++ Compiler Refer ence Guide T o ov erride the default new and delete operator for a class, declare: void *operator new(size_t); void operator delete(void *); as member functions, just lik e in ordinary C++. If a pointer to class memory cannot be implic itly casted into a de fault pointer type, no tem[...]
-
Seite 137
CA VR-4 Part 1. Using the compiler Using C++ 115 Use this syntax if you want to ove rride both global and class-specif ic operator new and operator delete for an y data memory . Note that there is a speci al syntax to name the operator new functions for each memory , while the naming for the operator delete functions relies on normal ove rloading. [...]
-
Seite 138
CA VR-4 116 Feature description s A VR® IAR C/C++ Compiler Refer ence Guide T emplates and data memory attributes For data memory attribu tes to work as e xpected in templat es, two elements of t he standard C++ template ha ndling ha ve been change d—class templa te partial specialization matching and functio n templ ate parameter deduction. In [...]
-
Seite 139
CA VR-4 Part 1. Using the compiler Using C++ 117 For templates that are matched using thi s modified algorithm, it is impossible to get automatic generatio n of special code for pointers to small memory t ypes. For lar ge and “other” memory types (memory that cannot be pointed to by a default pointer) it is possible. In order to make it possibl[...]
-
Seite 140
CA VR-4 118 Feature description s A VR® IAR C/C++ Compiler Refer ence Guide Example vector<int> d; // d placed in default memory, using // the default heap, uses default // pointers vector<int _ _near> _ _near x; // x placed in near memory, heap // allocation from near, uses // pointers to near memory vector<int _ _huge> _ _near [...]
-
Seite 141
CA VR-4 Part 1. Using the compiler Using C++ 119 NAMESPACE The namespace feature is only supported in Extended EC++. This means that you can use namespaces to partition your code. Note, ho we v er , that the library itself is not placed in the std namespace. THE STD NAMESPACE The std namespace is not used in either st andard EC++ or in Extended EC+[...]
-
Seite 142
CA VR-4 120 Feature description s A VR® IAR C/C++ Compiler Refer ence Guide T o av oid interrupts, plac e a call to the intrinsi c function _ _disable_interrupt before the call to _exit .[...]
-
Seite 143
CA VR-4 Part1. Using the compiler 121 Efficient coding for embedded a pplications For embedded systems, the size of th e generated code and data is ver y impor tant, because using smaller external memor y or on-chip memor y can significantly decr ease the cost and power consumption of a system. This chapter giv es an overview about how to write cod[...]
-
Seite 144
CA VR-4 122 T aking advantage of the compilation system A VR® IAR C/C++ Compiler Refer ence Guide CONTR OLLING COMPILER OPTIMIZ ATIONS The A VR IAR C/C++ Compiler allo ws you to specify whether ge nerated code should be optimized for size or for spe ed, at a selectable optimiz ation le vel. The purpose of optimization is to reduce the cod e size a[...]
-
Seite 145
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 123 Both compiler options and pr agma directi ves are a vailabl e for specifying the preferred type and lev el of opti mization. The chapt er Compiler options contains reference information about the comman d line options used for spec ifying optimization type and lev el.[...]
-
Seite 146
CA VR-4 124 T aking advantage of the compilation system A VR® IAR C/C++ Compiler Refer ence Guide Code motion Evaluation of loop-in variant expressions and common sube xpressions are mov ed to av oid redundant re-ev aluation. This optimization, which is performed at optimization lev el Medium , normally reduces code size and exec ution time. The r[...]
-
Seite 147
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 125 Clustering of variables When clustering of v aria bles is enabled, st atic and global variable s are arr anged so that v ariables that are accessed in the same function are stored cl ose to each other . This makes it possible for t he compiler to use the same base poi[...]
-
Seite 148
CA VR-4 126 Selecting data types and placing dat a in memory A VR® IAR C/C++ Compiler Refer ence Guide Putting strings in flash This can be done on individual strings or for the whole ap plication/ file using the option --string_literals_in_flash . Examples on how to put indi vidual strings into flash: _ _flash char str1[] = "abcdef"; _ [...]
-
Seite 149
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 127 For details about representation of supported data types, point ers, and structur es types, see the chapter Data r eprese ntation . Floating-point types Using floating-point types on a micr oproces sor without a math coprocessor is ve ry ineff icient, both in terms of[...]
-
Seite 150
CA VR-4 128 Selecting data types and placing dat a in memory A VR® IAR C/C++ Compiler Refer ence Guide MEMOR Y MODEL AND MEMOR Y ATTRIBUTES FOR DATA For man y applications it is suff icient to use the memory model feature to specify the default memory for the data objects. Ho wev er, for indi vidual objects it might be necessary to specify other m[...]
-
Seite 151
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 129 Example In the follo wing example, the memb ers in the anon ymous union can be accessed, in function f , without explicitly specifying the union name: struct s { char tag; union { long l; float f; }; } st; void f(void) { st.l = 5; } The member names must be unique in [...]
-
Seite 152
CA VR-4 130 Writing efficient code A VR® IAR C/C++ Compiler Refer ence Guide Anonymous structures and unions are implemented in terms of objects named a fter the first f ield, with a prefix _A to place the name in the implementation par t of the namespace. In this example, the anonym ous unio n will be implemented through an object named _A_IOPORT[...]
-
Seite 153
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 131 SA VING STACK SPACE AND RAM MEMOR Y The following is a list of programming tec hniques that will, when followed, sav e memory and stack space: ● If stack space is limited, av oid long call chains and recursi ve functions. ● A void using larg e non-scalar type s, s[...]
-
Seite 154
CA VR-4 132 Writing efficient code A VR® IAR C/C++ Compiler Refer ence Guide INTEG ER TYPES AND BIT NEGATION There are situation s when the rules for integer types and their con version lead to possibly confusing beha vior . Things to look out for are assignments or conditionals (test expressions) in volving types with different size and logical o[...]
-
Seite 155
CA VR-4 Part1. Using the compiler Efficient coding f or embedded applications 133 Pr otecting the eeprom write mechanism A typical example of when it can be necessary to use the _ _monitor keyword is when protecting the eeprom write mechanism, wh ich can be used from two threads (for example, main code and inte rrupts). Servicing an interrupt durin[...]
-
Seite 156
CA VR-4 134 Writing efficient code A VR® IAR C/C++ Compiler Refer ence Guide NON-INITIALIZED VARIABLES Normally , the runtime en vironment will initi alize all global and static v ariables when the application is started. The compiler supports the declaration of vari ables that will not be initialized, using the _ _no_init type modifi er . They ca[...]
-
Seite 157
CA VR-4 135 P ar t 2. Compiler re f e re n c e This part of the A VR® IAR C/C++ Compiler Reference Guide contains the follo wing chapters: ● Data repr esentation ● Se g m e n t re f e re nc e ● Compiler options ● Extended ke ywor ds ● Pragma directiv es ● The prepr ocessor ● Intrinsic functions ● Librar y functions ● Implementati[...]
-
Seite 158
CA VR-4 136[...]
-
Seite 159
CA VR-4 Part 2. Compiler refe rence 137 Data r epr esentation This chapter describes the data t ypes, pointers, and structure types supported by the A VR IAR C/C++ Compiler . See the chapter Eff icient coding for embedded applications for info rmat ion a bo ut which data types and pointers provid e the most efficient code for y our application. Ali[...]
-
Seite 160
CA VR-4 138 Basic data types A VR® IAR C/C++ Compiler Refer ence Guide Basic data types The compiler supports both all ISO/ANSI C ba sic data types and some additional types. INTEGER T YPES The follo wing table gi ves the size an d range of each integer data type: Signed v ariables are represented us ing the two’ s complement form. Bool The bool[...]
-
Seite 161
CA VR-4 Part 2. Compiler refe rence Data repr esentation 139 The char type The char type is by default unsigned in the compiler , but the --char_is_signed compiler option allows you to mak e it signed. Note, howev er, that the library is compiled with the char type as unsigned . The wchar_t type The wchar_t data ty pe is an intege r type whose rang[...]
-
Seite 162
CA VR-4 140 Basic data types A VR® IAR C/C++ Compiler Refer ence Guide * Depends on whether the --64bit_doubles option is used, see --64b it_doubles , page 201 . The type long double use the same precisi on as double . 32-bit floating-point format The representation of a 32-bit floati ng-poin t number as an integer is: The value of the number is: [...]
-
Seite 163
CA VR-4 Part 2. Compiler refe rence Data repr esentation 141 The va lue of a denormalized number is: (-1) S * 2 (1-BIAS) * 0.Mantissa where BIAS is 127 and 1023 for 32-bit and 64-bit floating-point va lues, respectively . Note: The IAR CLIB Library does not fully suppor t the special cases of floating-point numbers, such as infinity, NaN , and subn[...]
-
Seite 164
CA VR-4 142 Pointer types A VR® IAR C/C++ Compiler Refer ence Guide CASTING Casts betwee n pointers have the following characteristics : ● Casting a value of an inte ger type to a pointer of a smaller type is performed by truncation ● Casting a value of an inte ger type to a pointer of a larger type is perform ed by zero extens ion ● Casting[...]
-
Seite 165
CA VR-4 Part 2. Compiler refe rence Data repr esentation 143 ptrdiff_t ptrdiff_t is the type of the signed integer requi red to hold the dif ference between two pointers to elements of the same a rray . The follo wing table shows t he typedef of ptrdiff_t depending on the processor option: Note: Subtracting the start address of an object from the e[...]
-
Seite 166
CA VR-4 144 Ty p e a n d o b j e c t a t t r i b u t e s A VR® IAR C/C++ Compiler Refer ence Guide Example struct { short s; /* stored in byte 0 and 1 */ char c; /* stored in byte 2 */ long l; /* stored in byte 4, 5, and 6 */ char c2; /* stored in byte 7 */ } s; The follo wing diagram shows the layout in memory: The alignment of the structure is 1[...]
-
Seite 167
CA VR-4 Part 2. Compiler refe rence Data repr esentation 145 T ype attributes can be fur ther divided into memory attributes and general type attributes . Memor y attributes A memory attribute corresponds to a cer tain logical or physical memory in the microcontroller. ● Av a i l a b l e memory attribut es for func tions : _ _nearfunc , and _ _fa[...]
-
Seite 168
CA VR-4 146 Ty p e a n d o b j e c t a t t r i b u t e s A VR® IAR C/C++ Compiler Refer ence Guide DECLARING OBJECTS IN SOU RCE FILES When declaring obj ects, note that the IAR-specif ic attrib utes work exact ly like const . One exception to this is that attributes that are declared in front of the type specif ier apply to all declared objects. S[...]
-
Seite 169
CA VR-4 Part 2. Compiler refe rence Data repr esentation 147 The A VR IAR C/C++ Compiler adheres to these rules for all 8-bit types. The follo wing object types are treated in a special way: For all combinations of object types not listed, only rule number one applies. Data types in C++ In C++, all plain C data types are represented in the same w a[...]
-
Seite 170
CA VR-4 148 Data types in C++ A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 171
CA VR-4 Part 2. Compiler refe rence 149 Segment r efer ence The A VR IAR C/C++ Compiler places co de and data into named segments which are r eferr ed to by the IAR XLINK Link er™. Details about the segments are r equired for pr ogramming assembler la nguage modules, and are also useful when interpreti ng the assembler la nguage output from the c[...]
-
Seite 172
CA VR-4 150 Summary of segments A VR® IAR C/C++ Compiler Refer ence Guide HEAP Holds the heap used f or dynamically allocated data using the CLIB library . DATA HUGE_C Holds _ _huge declared constant data, including literal strings. DATA HUGE_F Holds static and global _ _hugeflash variables. CODE HUGE_HEAP Holds the heap used for dynamicall y al l[...]
-
Seite 173
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 151 Descriptions of segments The follo wing section giv es reference inform ation about each segment. F or detailed information about the extended k eywor ds mentioned here, see the chapter Extended ke ywor ds . CODE Holds _ _nearfunc program code. XLINK segment memor y type CODE Memory sp[...]
-
Seite 174
CA VR-4 152 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide Description Holds the internal data stack. This se gment and its length is normally defin ed in the linker command f ile with the follo wing command: -Z(DATA)CSTACK+ nn = start or -Z(DATA)CSTACK= start - end where nn is the length, start is the f i rst memory location,[...]
-
Seite 175
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 153 EEPROM_I Holds non-zero initializ ed static and global _ _eeprom var i a b l es . XLINK segment memor y type XDATA Memory space EEPR OM. Description Holds static and global _ _eeprom v ariables that hav e been defined with non-zero initial values. This se gment is not copied to EEPROM [...]
-
Seite 176
CA VR-4 154 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide Description Holds user program code that has been declared _ _farfunc . The _ _farfunc memory attribu te is av ailable when using the -v5 and -v6 options, in which case the _ _farfunc is implicitly used for all functions. FAR_C Holds _ _far constant data, incl uding st[...]
-
Seite 177
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 155 FAR_HEAP Holds the heap used for dynamically alloca ted data in far memory when using the DLIB library . XLINK segment memor y type DATA Memory space Data. The address range is 0x0–0xFFFFFF . Description This segment holds dynamically allocated data in far memory , in other words dat[...]
-
Seite 178
CA VR-4 156 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide FAR_ID Holds _ _far v ariable initiali zers. XLINK segment memor y type CODE Memory space Flash. The add ress range is 0x0–0x7FFFFF . Description Holds initial v alues for the variable s located in the FAR_I segment. These v alues are copied from FAR_ID to FAR_I duri[...]
-
Seite 179
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 157 HEAP Used for the he ap when using the CLIB library . XLINK segment memor y type DATA Memory space Data. The address range depe nds on t he memory model: Description Holds the heap used for d ynamically allocated data. This segment and its length is normally defined in the linker comma[...]
-
Seite 180
CA VR-4 158 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide HUGE_F Holds static and global _ _hugeflash var i a bl e s . XLINK segment memor y type CODE Memory space Flash. The add ress range is 0x0–0xFFFFFF . Description Holds static and global _ _hugeflash v ariables and aggregate initiali zers. HUGE_HEAP Holds the heap use[...]
-
Seite 181
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 159 Memory space Data. The address range is 0x0–0xFFFFFF . Description Holds static and global _ _huge v ariables that ha ve been de f ined with non-zero initial va lu e s . When the -y compiler option is used, _ _huge constant data is l ocated in this se gment. HUGE_ID Holds _ _huge v a[...]
-
Seite 182
CA VR-4 160 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide HUGE_Z Holds zero-initia lized static and global _ _huge va ri a b l e s . XLINK segment memor y type DATA Memory space Data. The address range is 0x0–0xFFFFFF . Description Holds static and global _ _huge va riables that have been de clared without initial v alues o[...]
-
Seite 183
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 161 NEAR_C Holds _ _tiny and _ _near constant data, incl uding string literals. XLINK segment memor y type CONST Memory space Data. The address range is 0x0–0xFFFF . Description Holds _ _tiny and _ _near constant data, incl uding string literals. Note: This segment is located in external[...]
-
Seite 184
CA VR-4 162 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide This segment and its length is normally defined in the linker command f ile by the command: -Z(DATA)NEAR_HEAP+ nn = start where nn is the length and start is the locat ion. For more information a bout dynamically allocated data and the heap, see The return addr ess sta[...]
-
Seite 185
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 163 NEAR_N Holds _ _no_init static and global _ _near vari ab l es . XLINK segment memor y type DATA Memory space Data. The address range is 0x0–0xFFFF . Description Holds static and global _ _near v aria bles that will not be in itialized at system startup, for example v ariables that a[...]
-
Seite 186
CA VR-4 164 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide SWITCH Holds switch tables for all functions. XLINK segment memor y type CODE Memory space Flash. The address range is 0x0–0xFFFF . If the _ _farflash e xtended keyword and the --enhanced_core option are used, the range is 0x0 – 0x7FFFFF . This s egment must not cr[...]
-
Seite 187
CA VR-4 Part 2. Compiler refe rence Se gm en t ref ere nc e 165 This segment and its length is normally defined in the linker command f ile by the command: -Z(DATA)TINY_HEAP+ nn = start where nn is the length and start is the locat ion. For more information a bout dynamically allocated data and the heap, see The return addr ess stack , page 43. For[...]
-
Seite 188
CA VR-4 166 Descriptions of s egments A VR® IAR C/C++ Compiler Refer ence Guide TINY_N Holds _ _no_init static and global _ _tiny vari ab l es . XLINK segment memor y type DATA Memory space Data. The address range is 0x0–0xFF . Description Holds static and global _ _tiny v aria bles that will not be in itialized at system startup, for example v [...]
-
Seite 189
CA VR-4 Part 2. Compiler refe rence 167 Compiler options This chapter explains how to set th e co mpiler options fr om the command line , and gives detailed r eference infor mation about each option. Refer to the A V R® IAR Embedded W orkbenc h™ IDE User Guide for in form at ion about the compiler op tions a vailable in IAR E mbedded W orkbench [...]
-
Seite 190
CA VR-4 168 Setting comm and line optio ns A VR® IAR C/C++ Compiler Refer ence Guide SPECIFYING PARAMETERS When a parameter is needed for an option w ith a short name, it can be specifie d either immediately following the optio n or as the next command line ar gument. For instance, an include file path of usrinclud e can be specified either as: [...]
-
Seite 191
CA VR-4 Part 2. Compiler refe rence Compiler options 169 SPECIFYING EN VIRONMENT VARIAB LES Compiler options can also be spec ified in the QCCAVR en vironment v ariable. The compiler automatic ally appends the value of this v ariable to e very command line, so it provides a con venient method of specifying options that are required for e very compi[...]
-
Seite 192
CA VR-4 170 Options summary A VR® IAR C/C++ Compiler Refer ence Guide -D symbol [= value ] Defines preprocessor symbols --debug Generates debug info rmation --dependencies[=[i|m]] { filename | directory } Lists file dependencies --diag_error= tag , tag ,... T reats these as err ors --diag_remark= tag , tag ,... T reats these as re marks --diag_sup[...]
-
Seite 193
CA VR-4 Part 2. Compiler refe rence Compiler options 171 -I path Specifies include file path --initializers_in_flash Places aggregate in itializers in flash memor y -l[a|A|b|B|c|C|D][N][H] { filename | directory } Cr eates a list file --library_module Creates a library mo dule --lock_regs N Locks registers -m name Memory model --memory_model= name [...]
-
Seite 194
CA VR-4 172 Options summary A VR® IAR C/C++ Compiler Refer ence Guide --omit_types Excludes t ype informatio n --only_stdout Uses standard output only --preinclude includefile Includes an include file before reading the sour ce file --preprocess[=[c][n][l]] { filename | directory } Gener ates prepr ocessor output --public_equ symbol [= value ] Def[...]
-
Seite 195
CA VR-4 Part 2. Compiler refe rence Compiler options 173 Descriptions of options The following section gi ves de tailed reference inf ormation about each compiler option. --char_is_signed --char_is_signed By default, the compiler int erprets the char type as unsigned. The --char_is_signed option causes the co mpiler to interpret the char type as si[...]
-
Seite 196
CA VR-4 174 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide --cross_call_passes --cross_call_passes= N Use this option to decrease the RSTACK usage b y running the cross-call optimizer N times, where N can be 1–5. The default is to run it until no more impro vements can be made. For additional information, see --no_cr oss_call[...]
-
Seite 197
CA VR-4 Part 2. Compiler refe rence Compiler options 175 Production v ersion: iccavr prog Te s t v e r s i o n : iccavr prog -DTESTVER T o set the equi va lent option in IAR Embedded W ork bench, select Project>Options>C/ C++ Compiler>Preprocessor . --debug, -r --debug -r Use the --debug or -r option to make the compile r include informati[...]
-
Seite 198
CA VR-4 176 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide For exa mp le : foo.r90: c:iarproductincludestdio.h foo.r90: d:myprojectincludefoo.h Example 1 T o generate a listing of fi le dependencies to the file listing.i , use: iccavr prog --dependencies=i listing Example 2 T o generate a listing of file dependencies to [...]
-
Seite 199
CA VR-4 Part 2. Compiler refe rence Compiler options 177 T o set the equi va lent option in IAR Embedded W ork bench, select Project>Options>C/C ++ Compiler>Diagnostics . --diag_remark --diag_remark= tag , tag,... Use this option to classify di agnostic messages as remarks. A remark is the least se vere type of diagnostic mess age and indi[...]
-
Seite 200
CA VR-4 178 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide --diagnostics_tables --diagnostics_tables { filename | directory } Use this option to list all po ssible diagnostic messages in a named file. This can be very con venient, for e xample, if you have used a pragma directive to s uppress o r change the se verity lev el of [...]
-
Seite 201
CA VR-4 Part 2. Compiler refe rence Compiler options 179 If you b uild your o wn customized runtime library , you should also create a corresponding customized library conf iguratio n file, which must be specified to th e compiler . For more informa tion, see Building and using a cu stomized library , page 62. Note: This option only applies to th e[...]
-
Seite 202
CA VR-4 180 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide --eec++ --eec++ In the A VR IAR C/C++ Compiler , the default language is C. If you take adv antage of Extended Embedded C++ features lik e namespac es or the standard template library in your source code, you must use this option to set the language the compiler uses to[...]
-
Seite 203
CA VR-4 Part 2. Compiler refe rence Compiler options 181 --enable_external_bus --enable_external_bus This option will make the co mpiler add the special _ _require statem ent which will make XLINK include the code in cstartup.s90 that enables the e xternal data b us. Use this option if you intend to place RST A CK in external RAM. Note: The code in[...]
-
Seite 204
CA VR-4 182 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide -f -f filename Reads command line options from the na med file, with the def ault extension xcl . By default , the compiler accepts comm and parameters only from the c ommand line itself and the QCCAVR en vironment variable. T o make long command lines more manageable, [...]
-
Seite 205
CA VR-4 Part 2. Compiler refe rence Compiler options 183 --header_context --header_context Occasionally , to find the cause of a problem it is necessary to know which header file was included from which source line. Use this option to list, for each diagnostic message, not only the source pos ition of the problem, b ut also the entire in clude stac[...]
-
Seite 206
CA VR-4 184 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide Then the fol lowing directorie s are searched i n the order listed belo w for the f ile config.h , which in this examp le is located in the dirdebugconfig directory: dirinclude Current file. dirsrc File including current f ile. dirinclude As specifi ed with the firs[...]
-
Seite 207
CA VR-4 Part 2. Compiler refe rence Compiler options 185 -l -l[a|A|b|B|c|C|D][N][H] { filename | directory } By default, the compiler does not generate a listing. Use this option to generate a listing to a fil e. The following modifiers are a vailable: * This makes the li st file less useful as input to the assembler , but more useful for r eading [...]
-
Seite 208
CA VR-4 186 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide Example 2 If you compile the file mysource.c and want to generate a listing to a f ile mysource.lst in the working directory , you could use: iccavr mysource -l . Note: Both and / can be used as di rectory delimi ters. T o set the equi va lent option in IAR Embedded W[...]
-
Seite 209
CA VR-4 Part 2. Compiler refe rence Compiler options 187 By default the co mpiler generates code fo r the T i ny memory model for all processor options except -v4 and -v6 where the Small memory model is the def ault. Use the -m or the --memory_model option if you w ant to generate code for a dif ferent memory model. For e xample, to generate code f[...]
-
Seite 210
CA VR-4 188 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide If the compiler is unable to check for a rule , specifying the option for that rule has no effe ct. For instance, MISRA C rule 15 is a documentation issue, and the rule is not checked b y the compiler . As a consequence, specifying --misrac=15 has no ef fect. T o set th[...]
-
Seite 211
CA VR-4 Part 2. Compiler refe rence Compiler options 189 Example The follo wing example—in which %1 is an operating system variable containing the name of the source file—will gi ve duplicate name errors from the linker: preproc %1.c temp.c ; preprocess source, ; generating temp.c iccavr temp.c ; module name is ; always 'temp' T o av [...]
-
Seite 212
CA VR-4 190 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide For additional information, see --cr oss_call_passes , page 174. This option is related to the Optimization options in the C/C++ Co mpiler cate gory in IAR Embedded W orkbench. --no_cse --no_cse Use --no_cse to disable common s ube xpression elimination. At optimization[...]
-
Seite 213
CA VR-4 Part 2. Compiler refe rence Compiler options 191 --no_ubrof_messages --no_ubrof_messages Use this option to minimize the size of your application object f ile by excluding messages from the UBR OF fil es. A file size decrease of up to 60% can be expected. Note that the XLINK diagnostic me ssages will, howev er , be less useful when you use [...]
-
Seite 214
CA VR-4 192 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide --no_wrap_diagnostics --no_wrap_diagnostics By default, long lines in comp iler diagnostic messag es are broken into se veral lines to make the messag e easier to read. Use this opt ion to disable line wr apping of diagnostic messages. -o -o { filename | directory } Use[...]
-
Seite 215
CA VR-4 Part 2. Compiler refe rence Compiler options 193 --only_stdout --only_stdout Use this option to m ake the compiler use the st andard output stream ( stdout ) also for messages that a re normally direct ed to the error output stream ( stderr ). --preinclude --preinclude includefile Use this option to make the co mpiler include the specified [...]
-
Seite 216
CA VR-4 194 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide T o set the equi va lent option in IAR Embedded W orkbench, select Project>Options>C/ C++ Compiler>Preprocessor . --public_equ --public_equ symbol [= value ] This option is equiv alent to defining a label in assembler langu age by using the EQU directiv e and e[...]
-
Seite 217
CA VR-4 Part 2. Compiler refe rence Compiler options 195 --root_variables --root_variables Use this option to apply the _ _root extended k eyword to all gl obal and static variables. This will make sure that the v ariables are not remov ed by the IAR XLINK Linker . Notice that the --root_variables o ption is always a vailable, e ven if you do not s[...]
-
Seite 218
CA VR-4 196 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide For de scriptions of the av ailable memory attributes, see T able 7, Me mory attributes for data on page 19 and T able 8, Memory attrib utes for functions on page 28. F or a description of the segment name suf fixes, see Segment naming , page 37. --separate_cluster_for_[...]
-
Seite 219
CA VR-4 Part 2. Compiler refe rence Compiler options 197 -v -v[0|1|2|3|4|5|6] Use this option to select the pr ocessor deri vativ e for which th e code is to be generated. The follo wing processor variants are a vailable: Generic processor option Pro cessor variant Desc ription -v0 A T90S2313 A T90S2323 A T90S2333 A T90S2343 A T90S4433 AT t i n y 1[...]
-
Seite 220
CA VR-4 198 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide -v2 Reserved for fu ture derivatives The code space is physically limited to 128 Kbytes, and, if possible, the RCALL/RJMP inst ructions are used for reaching the code space. If that is not possible, CALL / JMP is used. Function calls thr ough function pointers use ICALL[...]
-
Seite 221
CA VR-4 Part 2. Compiler refe rence Compiler options 199 See also --cpu , page 173, and Pr ocessor configur ation , page 5. This option is related to the Processor configuration option in the General Options category in IAR Embedded W orkbench. --version1_calls --version1_calls This option is provide d for backward compatibility . It makes all func[...]
-
Seite 222
CA VR-4 200 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide --warnings_are_errors --warnings_are_errors Use this option to make the compi ler trea t all warnings as errors. If the compiler encounters an error , no object c ode is generated. W arnings th at have been changed into remarks are not treated as errors. Note: Any diagn[...]
-
Seite 223
CA VR-4 Part 2. Compiler refe rence Compiler options 201 *The most impor tant difference between -z2 and -z3 is that at lev el 2, all non-static variables will live during th eir entire scope. A low le vel of optimization ma kes it relativ ely easy to follow the program flow in the debugger , and, conv ersely , a high lev el of optimization mak es [...]
-
Seite 224
CA VR-4 202 Descriptions of op tions A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 225
CA VR-4 Part 2. Compiler refe rence 203 Extended k e yw or ds This chapter descr ibes the extended ke yw ords that support specific featur es of the A VR micr ocontroller, the general syntax rules for the k eywor ds, and a detailed description of each k eyw ord. For information about the ad dress ranges of the differ ent memory areas, see the chapt[...]
-
Seite 226
CA VR-4 204 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide The follo wing table summariz es the extende d k eywords that can be used on data: Descriptions of extended k eyw ords The follo wing sections giv e detailed information about each extended k eyword. @ The @ operator can be used for pl acing global and static[...]
-
Seite 227
CA VR-4 Part 2. Compiler refe rence Extended k eywords 205 asm, _ _asm The asm and _ _asm extended keywords both insert an assembler instruction. Howe ver , when compiling C source code, the asm keyw ord is not av ailable when the option --strict_ansi is used. Th e _ _asm keyword is alw ays available. Note: Not all assembler directives or operators[...]
-
Seite 228
CA VR-4 206 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide _ _ext_io Controls the storag e of data objects in dat a memory space. The _ _ext_io memory attribute implies tha t objects are _ _no_init and v olatile, and allo ws objects to be accessed by use of the special I/O instruction s in the A VR microcontroller . [...]
-
Seite 229
CA VR-4 Part 2. Compiler refe rence Extended k eywords 207 _ _farfunc Controls the storag e of functions in code memory space. The _ _farfunc memory attrib ute places a functi on in farfunc code memory space. Functions declared _ _farfunc have no restrictions on c ode placement , and can be placed anywhere in code memory . The default code pointer [...]
-
Seite 230
CA VR-4 208 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide Using the strcpy_P function d eclared in pgmspace.h , a string in flash memory can be copied to another string in RAM as follows: strcpy_P(dest, msg); _ _generic Declares a generic pointer . The _ _generic pointer type attribute declares a generic point er th[...]
-
Seite 231
CA VR-4 Part 2. Compiler refe rence Extended k eywords 209 _ _hugeflash Controls the storage of data obje cts in flash (code) memory space. The _ _hugeflash memory attribute places obj ects in flash (code) memory . Note that it is prefera ble to de clare flash objects as constant. The _ _hugeflash memory attribute is only a vailable for A VR chips [...]
-
Seite 232
CA VR-4 210 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide _ _intrinsic The _ _intrinsic keyword is reserv ed for compiler internal use only . _ _io Controls the storag e of data objects in I/O memo ry space, alternati vely data memory space. The _ _io memory attrib ute implies that ob jects are _ _no_init and vol at[...]
-
Seite 233
CA VR-4 Part 2. Compiler refe rence Extended k eywords 211 _ _nearfunc Controls the storag e of functions in code memory space. The _ _nearfunc memory attrib ute allows you to def ine the memory range where a function will be located. Functions declared _ _nearfunc can be call ed from the entire code memory area, but must reside in the f irst 128 K[...]
-
Seite 234
CA VR-4 212 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide _ _regvar The _ _regvar extended keyw ord is used for declaring t hat a global or static va r ia b l e should be placed permanently in the specified register or registers. The registers R4–R15 can be used for this purpose, pro vided that the y have be en lo[...]
-
Seite 235
CA VR-4 Part 2. Compiler refe rence Extended k eywords 213 _ _task Allo ws functions to exit wit hout restoring re gister s. This keyw ord is typically used for the main function. By default, functions sa ve the contents of used non-sc ratch registers (permanent registers) on the stack upon entry , and restor e them at e xit. Func tions declared as[...]
-
Seite 236
CA VR-4 214 Descriptions of ext ended key words A VR® IAR C/C++ Compiler Refer ence Guide _ _version_1 The _ _version_1 keyword is a vailable for backward com patibility . It makes a function use the calling con vention of the A90 IAR C Compiler instead of the defaul t calling con vention, both wh ich are described in Calling c onventio n , page 9[...]
-
Seite 237
CA VR-4 Part 2. Compiler refe rence 215 Pra gma dir ectiv es This chapter describes the pragma dir e ctives of the A VR IAR C/C++ Compiler . The pragma directiv es control the beha vi or of the compiler , for example how it allocates memory , whether it allows extended k eyw ords, and whether it outputs warning messages. The pragma directiv es are [...]
-
Seite 238
CA VR-4 216 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide Note: For portability reasons, some old-style pragma directives are recognized but will give a diagnostic message. It is important to be aware of this if you need to por t existing code that contains any of t hose pragma directives. For a dditional information[...]
-
Seite 239
CA VR-4 Part 2. Compiler refe rence Pragma dir ectives 217 #pragma bitfields #pragma bitfields={reversed|default} The #pragma bitfields directi ve controls the or der of bi tfield members. By default, the A VR IAR C/C++ Compile r places bitfiel d members from the least significant bit to the most signif icant bit in the container typ e. Use the #pr[...]
-
Seite 240
CA VR-4 218 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide The segment name cannot be a pred efined se gment, see the chapter Seg ment refer ence for more information. The v ariable myBuffer will not be initialized at startup, and can for this reason not ha ve an y initializer . The memory in which the segment resides[...]
-
Seite 241
CA VR-4 Part 2. Compiler refe rence Pragma dir ectives 219 #pragma diag_warning #pragma diag_warning= tag , tag ,... Changes the se verity le vel to warning for the specified d iagnostics. For example: #pragma diag_warning=Pe826 See the chapt er Diagnostics for more information a bout diagnostic messages. #pragma include_alias #pragma include_alias[...]
-
Seite 242
CA VR-4 220 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide #pragma language #pragma language={extended|default} The #pragma language directi ve is used for turning on the IAR language extensions or for using the language settings specified on the command line: #pragma location #pragma location= address The #pragma loc[...]
-
Seite 243
CA VR-4 Part 2. Compiler refe rence Pragma dir ectives 221 The following k eywords can be used with #pragma object_attribute for a function or va riable: Example In the follo wing example, the v ariable bar is placed in the non-init ialized segment: #pragma object_attribute=_ _no_init char bar; Unlike the directi ve #pragma type_attribute th at spe[...]
-
Seite 244
CA VR-4 222 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide Note: If you use the #pragma optimize directive to specify an optimization level that is higher than the optimizat ion level you specify using a compiler option, the pragma directive is ignored. Example #pragma optimize=s 9 int small_and_used_often() { ... } #[...]
-
Seite 245
CA VR-4 Part 2. Compiler refe rence Pragma dir ectives 223 #pragma required #pragma required= symbol Use the #pragma required directi ve to ensure that a symbol which is needed by another symbol is present in the linked output. The symbol can be any statically linke d function or variable, and the pragma directi ve must be pl aced immediate ly befo[...]
-
Seite 246
CA VR-4 224 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide #pragma segment #pragma segment=" segment " [ memattr ] [ align ] The #pragma segment directiv e declares a segment na me that can be used by the intrinsic functions _ _segment_begin and _ _segment_end . All segment declarations for a specif ic segme[...]
-
Seite 247
CA VR-4 Part 2. Compiler refe rence Pragma dir ectives 225 #pragma vector #pragma vector= vector1 [, vector2 , vector3 , ...] The #pragma vector directive specifies the vector(s) of an interrupt function w hose declaration follows the pragma direct iv e. Example #pragma vector=0x14 _ _interrupt void my_handler(void);[...]
-
Seite 248
CA VR-4 226 Descriptions of pr agma directives A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 249
CA VR-4 Part 2. Compiler refe rence 227 The pr epr ocessor This chapter g ives a brief ov er view of the pr epr ocessor , including r eference information about the diff erent prepr oce ssor directives, symbols, and other related information. Ov er vie w of the prepr ocessor The preprocessor of th e A VR IAR C/C++ Compiler ad heres to the ISO/ANSI [...]
-
Seite 250
CA VR-4 228 Predefined symbols A VR® IAR C/C++ Compiler Refer ence Guide SUMMARY OF PREDEF INED SYMBOLS The follo wing table summarizes the predefined symbols: Predefined symbol Identifies _ _ALIGNOF_ _ () Accesses the alignment of an object _ _BASE_FILE_ _ Identifies the name of the file being com piled. If the fi le is a header file, the name of[...]
-
Seite 251
CA VR-4 Part 2. Compiler refe rence The preprocessor 229 * This symbol is requir ed by the ISO/ANSI standard. Note: The predefined symbol _ _TID_ _ is available for backward compatibi lity. We recommend that you use the symbols _ _ICCAVR_ _ and _ _MEMORY_MODEL_ _ instead. DESCRIPTIO NS OF PREDEFINED SYMB OLS The follo wing section giv es reference [...]
-
Seite 252
CA VR-4 230 Predefined symbols A VR® IAR C/C++ Compiler Refer ence Guide _ _DATE_ _ Use t his symbol to identify when the f ile was comp iled. This symbol expa nds to the date of compilation, which is returned in the form "Mmm dd yyyy" , for example "Jan 30 2002" . __ derivative __ Use this symbol to identify the used processor[...]
-
Seite 253
CA VR-4 Part 2. Compiler refe rence The preprocessor 231 _ _HAS_ELPM_ _ This symbol determines wh ether the instruction ELPM is av ailable or not. When this symbol is def ined, the instruction ELPM is av ailable. When this symbol is not defined, the ELPM instru ction is not av ailable. _ _HAS_ENHANCED_CORE_ _ This symbol determines whether the enha[...]
-
Seite 254
CA VR-4 232 Predefined symbols A VR® IAR C/C++ Compiler Refer ence Guide _ _IAR_SYSTEMS_ICC_ _ This predefined symbol e xpands to a number that ident ifies the IAR compil er platform. The current identif ier is 6. Note that the num ber could be higher in a future version of the product. This symbol can be tested with #ifdef to detect whether th e [...]
-
Seite 255
CA VR-4 Part 2. Compiler refe rence The preprocessor 233 _Pragma() The preprocessor operator _Pragma can be used in defines and has the equiv alent effect of the #pragma directi ve. The syntax is: _Pragma(" string ") where stri ng follows the syntax for the correspondi ng pragma directi ve. For example: #if NO_OPTIMIZE #define NOOPT _Prag[...]
-
Seite 256
CA VR-4 234 Predefined symbols A VR® IAR C/C++ Compiler Refer ence Guide ● The value ( m ) corresponding to the --memory_model option in use; where the valu e 1 corresponds to Tin y , the value 2 corresponds to Small, and the value 3 corresponds to Large. The _ _TID_ _ value is constructed as: ((t << 8) | (c << 4) | m) Y ou can extra[...]
-
Seite 257
CA VR-4 Part 2. Compiler refe rence The preprocessor 235 For detailed information about the calling con ventions, see Calling con vention , page 99 . Pr eprocessor e xtensions The follo wing section giv es reference info rmation about the extensions that are av ailable in addition to the pragma directi ves and ISO/ANSI directiv es. #warning message[...]
-
Seite 258
CA VR-4 236 Prepr ocessor extensions A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 259
CA VR-4 Part 2. Compiler refe rence 237 Intrinsic functions This chapter giv es refer ence inform ation about the intrinsic functions. The intrinsic functions pr ovide direct a ccess to low-level pr ocessor operations and can be very useful in, for example, time-critical routin es. The intrinsic functions compile in to inline code , either as a sin[...]
-
Seite 260
CA VR-4 238 Descriptions of int rinsic functions A VR® IAR C/C++ Compiler Refer ence Guide T o use intrinsic fun ctions in an a pplication, include the header f ile intrinsics.h . Note that the intrinsic function names start with double underscores, for example: _ _segment_begin Descriptions of intrinsic functions The follo wing section giv es ref[...]
-
Seite 261
CA VR-4 Part 2. Compiler refe rence Intrinsic functions 239 _ _fractional_multiply_signed signed int _ _fracdtional_multiply_signed(signed char, signed char); Generates a FMULS instruction. _ _fractional_multiply_signed_ with_unsigned signed int _ _fractional_multiply_signed_with_unsigned(signed char, unsigned char); Generates a FMULSU instruction.[...]
-
Seite 262
CA VR-4 240 Descriptions of int rinsic functions A VR® IAR C/C++ Compiler Refer ence Guide _ _multiply_unsigned unsigned int _ _multiply_unsigned(unsigned char, unsigned char); Generates a MUL instruction. _ _no_operation void _ _no_operation(void); Generates a NOP instruction. _ _require void _ _require(void *); Sets a constant literal as requ ir[...]
-
Seite 263
CA VR-4 Part 2. Compiler refe rence Intrinsic functions 241 signed int _ _reverse( signed int); unsigned long _ _reverse(unsigned long); signed long _ _reverse( signed long); void _ _far * _ _reverse(void _ _far *); /* Only on -v4 */ /* and -v6 */ void _ _huge * _ _reverse(void _ _huge *); /* Only on -v4 */ /* and -v6 */ void _ _farflash * _ _rever[...]
-
Seite 264
CA VR-4 242 Descriptions of int rinsic functions A VR® IAR C/C++ Compiler Refer ence Guide Note: You must have enabled language extens ions to use this intrinsic function. _ _segment_end void * _ _segment_end( segment ); Returns the address of the f irst byte after the named segment . The named segment must be a string l iteral that has been decla[...]
-
Seite 265
CA VR-4 Part 2. Compiler refe rence 243 Librar y functions This chapter gives an intr oduction to the C and C+ + library functions . It also lists the header files used for accessing librar y definitions. At the end of this chapter , all A VR-specific librar y function s are described. For detailed r eference information about the librar y function[...]
-
Seite 266
CA VR-4 244 IAR DLIB Librar y A VR® IAR C/C++ Compiler Refer ence Guide LIBRARY OBJECT FILES Most of the library def initions can be used without modif ication, th at is, directly from the library object files that are supp lied with the product. For information about how to choose a runtime library , see Basic settings for pr oject configur ation[...]
-
Seite 267
CA VR-4 Part 2. Compiler refe rence Library functions 245 ● Standard C library definitions, for user programs. ● Embedded C++ library definitions, for user programs. ● CSTARTUP , the module containing the start-up code . It is described in the chapter The DLIB runtime en vir onment in this guide. ● Runtime support libraries; for exampl e lo[...]
-
Seite 268
CA VR-4 246 IAR DLIB Librar y A VR® IAR C/C++ Compiler Refer ence Guide C++ HEADER FILES This section lists th e C++ header files. Embedded C++ The follo wing table lists th e Embedded C++ header f iles: The follo wing table lists a dditional C++ header f iles: Header file Usa ge complex Defining a class that s uppor ts complex arithmetic exceptio[...]
-
Seite 269
CA VR-4 Part 2. Compiler refe rence Library functions 247 Extended Embedded C++ standard template library The follo wing table lists the Extended Embe dded C++ standard temp late library (STL) header files: Using standard C libraries in C++ The C++ library w orks in conj unction with 15 of the header f iles from the standard C library , sometimes w[...]
-
Seite 270
CA VR-4 248 IAR CLIB Librar y A VR® IAR C/C++ Compiler Refer ence Guide LIBRARY FUNCTIONS AS INTRINSIC FUNCTIONS The following C library functi ons will under some circumstan ces be handled as intrinsic functions and will generate inline code instead of an ordinary function call: memcpy memset strcat strcmp strcpy strlen IAR CLIB Librar y The IAR [...]
-
Seite 271
CA VR-4 Part 2. Compiler refe rence Library functions 249 LIBRAR Y DEFINIT IONS SUMMAR Y This section l ists the header files. Head er files may additionally co n tain target-specific definitions. * The functions is xxx , toupper , and tolower declared in the header file ctype.h eva l ua t e their argume nt more than once. This is not accordi ng to[...]
-
Seite 272
CA VR-4 250 A VR–specific librar y functions A VR® IAR C/C++ Compiler Refer ence Guide SPECIFYING READ AND W RITE FORMATTERS Y ou can override default fo rmatters for the functions printf_P and scanf_P by editing the linker command f ile. Note that it is n ot possible to use the IAR Embedded W orkbench interface for o verriding the defau lt form[...]
-
Seite 273
CA VR-4 Part 2. Compiler refe rence Library functions 251 puts_P int puts_P(PGM_P _ _s); Identical to puts except that the string to be writte n is in flash memo ry , not in data memory . This function is av ailable in both the CLIB and the DLIB lib rary . scanf_P int scanf_P(PGM_P _ _format,…); Identical to scanf except that the format string is[...]
-
Seite 274
CA VR-4 252 A VR–specific librar y functions A VR® IAR C/C++ Compiler Refer ence Guide strcpy_P char * strcpy_P(char *s1, PGM_P s2); Identical to strcpy except that the string s2 being copied is in fl ash memory , not in data memory . This function is av ailable in both the CLIB and the DLIB lib rary . strerror_P PGM_P strerror_P(int errnum); Id[...]
-
Seite 275
CA VR-4 Part 2. Compiler refe rence Library functions 253 strncpy_P char * strncpy_P(char *s1, PGM_P s2, size_t n); Identical to strncpy except that the source string s2 is in flash memory , not in data memory . This function is av ailable in both the CLIB and the DLIB lib rary .[...]
-
Seite 276
CA VR-4 254 A VR–specific librar y functions A VR® IAR C/C++ Compiler Refer ence Guide[...]
-
Seite 277
CA VR-4 Part 2. Compiler refe rence 255 Implementation-defined beha vior This chapter de scribes how the A V R IAR C/C++ Compiler handles the implementation-defined areas of the C language. ISO 9899:1990, the International Organiz ation for Standardization standard - Pro gramming Languages - C (r evision and redesign of ANSI X3.159-1989, American N[...]
-
Seite 278
CA VR-4 256 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide EN VIRONMENT Arguments to main (5.1.2.2.2.1) The function called at program startup is called main . There is no prototype declared for main , and the only definition supported for main is: int main(void) T o change this behavior for the IAR CLI[...]
-
Seite 279
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 257 See Locale , page 71. Bits per character in ex ecution character set (5.2.4.2.1) The number of bits in a character is represented by the manifest constant CHAR_BIT . The standard include file limits.h def ines CHAR_BIT as 8. Mapping of characters (6.1.3.4) The mapping of memb[...]
-
Seite 280
CA VR-4 258 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide INTEGERS Range of integ er values (6.1.2.5) The representation of inte ger values are in the two's com plement form. The most significant bit holds the sign; 1 for neg ative , 0 for positi ve and zero. See Basic data types , page 138, for i[...]
-
Seite 281
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 259 Demoting floating-point values (6.2.1.4) When a floating-point va lue is conv erted to a floating-point value of narrower typ e that cannot exactly represent the v alue, the value is rounded (up or do wn) to the nearest suitable v alue. ARRA YS AND POINT ERS size_t (6.3.3 .4,[...]
-
Seite 282
CA VR-4 260 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide Allocation order of bitfields within a unit (6.5.2.1) Bitfiel ds are allocated within an integer from least-significant to m ost-significant bit. Can bitfields straddle a storag e-unit boundar y (6.5.2.1) Bitfields cannot str addle a st orage-un[...]
-
Seite 283
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 261 Including bracketed filenames (6.8.2) For f ile specif ications enclosed in angl e brackets, the preprocessor does not search directories of the parent file s. A parent f ile is the fi le that contains the #include directiv e. Instead, it begins b y searching for the file in [...]
-
Seite 284
CA VR-4 262 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide include_alias inline instantiate language location memory message module_name none no_pch NOTREACHED object_attribute once optimize pack _ _printf_args public_equ required rtmodel _ _scanf_args segment system_include type_attribute VARARGS vecto[...]
-
Seite 285
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 263 Domain errors (7.5.1) HUGE_VAL , the lar gest representable v alue in a double floating-point type, will be returned b y the mathematic functions on domain errors. Underflo w of floating-point values sets errno to ERANGE (7.5.1) The mathemati cs functions se t the integer e x[...]
-
Seite 286
CA VR-4 264 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide %p in printf() (7.9.6.1) The argument to a %p conv ersion specifier , print pointer , to printf() is trea ted as having the type 'char *' . The v alue will be printed as a hexadecimal number , similar to using the %x con version specif[...]
-
Seite 287
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 265 Messag e returned b y strerr or() (7.11.6.2) The messages returned by strerror() depending on the ar gument are: The time zone (7.12.1) The time zone func tion is not supported. clock() (7.12.2.1) The clock() function is not supported. IAR DLIB LIBRARY FUNCTIONS The informati[...]
-
Seite 288
CA VR-4 266 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide fmod() functionality (7.5.6. 4) If the second argument to fmod() is zer o, the function returns NaN ; errno is set to EDOM . signal() (7.7.1.1) The signal part of the library is not supported. Note: Low-level interfac e functions exist in the li[...]
-
Seite 289
CA VR-4 Part 2. Compiler refe rence Implementation-de fined beha vior 267 %p in printf() (7.9.6.1) The argument to a %p conv ersion specifier , print pointer , to printf() is trea ted as having the type void * . The v alue will be printed as a he xadecimal number, similar to using the %x con version specif ier . %p in scanf() (7.9.6.2) The %p con v[...]
-
Seite 290
CA VR-4 268 Descriptions of implem en tation-defined behavior A VR® IAR C/C++ Compiler Refer ence Guide system() (7.10.4.5) How the command processor works depend s on how y ou have implemented the system function. See En vironment interaction , page 73. Messag e returned b y strerr or() (7.11.6.2) The messages returned by strerror() depending on [...]
-
Seite 291
CA VR-4 Part 2. Compiler refe rence 269 IAR langua g e extensions This chapter describes IAR language extensions to the ISO/ANSI standar d for the C programming language. All extensions can also be used for the C++ pr ogramming langu age . In the IAR Embedded W orkbench™ IDE, language extensions are enabled by default. See the compiler options -e[...]
-
Seite 292
CA VR-4 270 Descriptions of langu age extensions A VR® IAR C/C++ Compiler Refer ence Guide See the chapter Extended keywor ds for a complete list of attrib utes. Placement at an absolute address or in a named segment The operator @ or the directiv e # pragma location can be used for placing a v ariable at an absolute a ddress, or placing a variab [...]
-
Seite 293
CA VR-4 Part 2. Compiler refe rence IAR languag e extensions 271 Inline assembler Inline assembler can be used for insertin g assembler instructions in the generated function. The syntax for inline assembler is: asm("MOVW R4,R7"); In strict ISO/ANSI mode, the use of inline assembler is disabled. For more details about inlin e assembler , [...]
-
Seite 294
CA VR-4 272 Descriptions of langu age extensions A VR® IAR C/C++ Compiler Refer ence Guide For e xample, the structure str in the following example co ntains an anonymous union. The members of the union are accessed using the names b and c , for example obj.b . W ithout anonymous structure types, the union would ha ve to be named—for example u ?[...]
-
Seite 295
CA VR-4 Part 2. Compiler refe rence IAR languag e extensions 273 Example struct str { char a; unsigned long b[]; }; struct str * GetAStr(int size) { return malloc(sizeof(struct str) + sizeof(unsigned long) * size); } void UseStr(struct str * s) { s->b[10] = 0; } The struct will inherit the alignment require ments from all elements, including the[...]
-
Seite 296
CA VR-4 274 Descriptions of langu age extensions A VR® IAR C/C++ Compiler Refer ence Guide Empty translation units A translation unit (source file) is allowed to be empty , that is, it does not have to contain any declarations. In strict ISO/ANSI mode, a warning is issu ed if the translation unit is empty . Example The follo wing source file is on[...]
-
Seite 297
CA VR-4 Part 2. Compiler refe rence IAR languag e extensions 275 Note: ISO/ANSI C allows extra c ommas in similar situations, for exam ple after the last element of the initial izers to an array. The re ason is, that it is ea sy to get the commas wrong if parts of the list are moved using a normal cut-and-paste operation. Example enum { kOne, kTwo,[...]
-
Seite 298
CA VR-4 276 Descriptions of langu age extensions A VR® IAR C/C++ Compiler Refer ence Guide The follo wing piece of code will generate a warning: switch (x) { case 1: ...; break; default: } A good way to conv ert this into a standa rd-compliant C program is to place a break; statement after the default: label. Empty declarations An empty declaratio[...]
-
Seite 299
CA VR-4 Part 2. Compiler refe rence IAR languag e extensions 277 Casting pointers to integers in static initializers In an initializer , a pointer cons tant value may be cast to an integral type if the integral type is large enough to contain it. In the follow ing example, it is assumed that pointers to _ _near and _ _huge are 16 and 32 bits, re sp[...]
-
Seite 300
CA VR-4 278 Descriptions of langu age extensions A VR® IAR C/C++ Compiler Refer ence Guide Repeated typedefs Redeclarations of typedef that occur in the same scope are allowed, but a w arning is issued. Mixing pointer types Assignment and pointer dif ference is al lowed between pointers to ty pes that are interchangeable but not identical; for e x[...]
-
Seite 301
CA VR-4 Part 2. Compiler refe rence 279 Dia gnostics This chapter describes the format of th e di agnostic messag es and explain s how diagnostic messages are divided into differ ent lev els of sev erity . Messag e format All diagnostic messages are issued as comp lete, self-explanatory messages. A typical diagnostic message from the compiler is pr[...]
-
Seite 302
CA VR-4 280 Seve ri ty leve ls A VR® IAR C/C++ Compiler Refer ence Guide Err or A diagnostic that is produced when the co mpiler has found a cons truct which clearly violates the C or C++ lang uage rules, such that code cannot be produced. An error will produce a non-zero exit code. Fat al error A diagnostic that is produced when the co mpiler has[...]
-
Seite 303
CA VR-4 Index 281 A absolute location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 7 #pragma location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 absolute placeme nt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 aggreg ate initializers, placing in flash memory . . . . . . . . . 184 algorith[...]
-
Seite 304
CA VR-4 282 A VR® IAR C/C++ Compiler Refer ence Guide C C and C++ linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 C calling con vention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 C header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 call chains . . . . . . . . . . . . . .[...]
-
Seite 305
CA VR-4 Index 283 locating _ _tiny v ariables . . . . . . . . . . . . . . . . . . . . 165 -z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 --char_is_signed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 --cpu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 mapp[...]
-
Seite 306
CA VR-4 284 A VR® IAR C/C++ Compiler Refer ence Guide const_cast (cast operator) . . . . . . . . . . . . . . . . . . . . . . . . . 110 con ventions, typographic . . . . . . . . . . . . . . . . . . . . . . . . . xxii copyright notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii _ _CORE_ _ (predefined symbol) . . . . . . . [...]
-
Seite 307
CA VR-4 Index 285 classifying as e rrors . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 classifying as re marks . . . . . . . . . . . . . . . . . . . . . . . . . 177 classifying as warnings . . . . . . . . . . . . . . . . . . . . . . . . 177 disabling warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 disabling wrapping[...]
-
Seite 308
CA VR-4 286 A VR® IAR C/C++ Compiler Refer ence Guide exception v ectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 exception (library header f ile) . . . . . . . . . . . . . . . . . . . . . . 246 experience, programming . . . . . . . . . . . . . . . . . . . . . . . . . xix export k eyword, missing from Extended EC++ . . . [...]
-
Seite 309
CA VR-4 Index 287 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 floating-point format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 – 127 implementation-de fined beha vior . . . . . . . . . . . . . . . . . 258 [...]
-
Seite 310
CA VR-4 288 A VR® IAR C/C++ Compiler Refer ence Guide C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 EC++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 errno.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 float.h . . . . . . . . . . . . . . . [...]
-
Seite 311
CA VR-4 Index 289 interrupt vectors, specifyin g with pragma directiv e . . . . . . 225 interrupts disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 disabling during f unction ex ecution . . . . . . . . . . . . . . . . 3 0 INTVEC segment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 processor state . [...]
-
Seite 312
CA VR-4 290 A VR® IAR C/C++ Compiler Refer ence Guide memcpy_G . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 memcpy_P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 printf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 7 printf_P . . . . . . . . . . . . . . . . . .[...]
-
Seite 313
CA VR-4 Index 291 malloc (standard library function) . . . . . . . . . . . . . . . . . . . . 25 map (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 math.h (library header file) . . . . . . . . . . . . . . . . . 83 , 245 , 249 _medium_write (library function) . . . . . . . . . . . . . . . . . . . . 88 memcmp_G (library [...]
-
Seite 314
CA VR-4 292 A VR® IAR C/C++ Compiler Refer ence Guide ne w (keyword) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 ne w (library header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 246 ne w .h (library header f ile) . . . . . . . . . . . . . . . . . . . . . . . . . 246 non-initialized variables . . . . . . . .[...]
-
Seite 315
CA VR-4 Index 293 implementation-de fined beha vior . . . . . . . . . . . . . . . . . 259 to constructor blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 152 using instead of larg e non-scalar parameters . . . . . . . . 131 polymorphism, in Embedded C++ . . . . . . . . . . . . . . . . . . 109 porting, of code containing pragma directi ves[...]
-
Seite 316
CA VR-4 294 A VR® IAR C/C++ Compiler Refer ence Guide preprocessor output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 preprocessor symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 NDEBUG . . . . . . . . . . . . . . . . . . . [...]
-
Seite 317
CA VR-4 Index 295 routines, time- critical . . . . . . . . . . . . . . . . . . . . . . . . . 9 3 , 237 RSEG (assembler direc tiv e) . . . . . . . . . . . . . . . . . . . . . . . . 81 RST A CK (segment) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 RST A CK, size of stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 R T[...]
-
Seite 318
CA VR-4 296 A VR® IAR C/C++ Compiler Refer ence Guide TINY_Z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 _ _segment_be gin (intrinsic function) . . . . . . . . . . . . . . . . 241 _ _segment_end (int rinsic function) . . . . . . . . . . . . . . . . . 242 SEI (assembler instruction) . . . . . . . . . . . . . . . . . [...]
-
Seite 319
CA VR-4 Index 297 stdio.h (library header f ile) . . . . . . . . . . . . . . . . . 83 , 245 , 249 stdlib .h (library hea der file) . . . . . . . . . . . . . . . . . 83 , 24 5 , 249 stdout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 , 193 STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .[...]
-
Seite 320
CA VR-4 298 A VR® IAR C/C++ Compiler Refer ence Guide type-safe memory management . . . . . . . . . . . . . . . . . . . . 109 type_attribute (pragma directi ve) . . . . . . . . . . . . . . . . . . . 224 typographic con ventions . . . . . . . . . . . . . . . . . . . . . . . . . . xxii U UBR OF messages, excluding from object file . . . . . . . . . [...]
-
Seite 321
CA VR-4 Index 299 -o (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 -r (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . 175 , 194 -s (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 -v (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 [...]
-
Seite 322
CA VR-4 300 A VR® IAR C/C++ Compiler Refer ence Guide _ _CORE_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . 229 _ _cplusplus (predefined symbol) . . . . . . . . . . . . . . . . . . . 229 _ _cpu (runtime model attribute) . . . . . . . . . . . . . . . . . . . . . 79 _ _CPU_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . .[...]
-
Seite 323
CA VR-4 Index 301 _ _sleep (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 242 _ _STDC_ _ (predefined symbol) . . . . . . . . . . . . . . . . . . . 233 _ _STDC_VERSION_ _ (predefined symbol) . . . . . . . . . 233 _ _swap_nibbles (int rinsic function) . . . . . . . . . . . . . . . . . 242 _ _task (extended k eyword) . . . . . . . [...]