The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

Programming Guide COPYRIGHT NOTICE Copyright 1995-1996 Syste


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



MSP430 COMPILER
Programming Guide
COPYRIGHT NOTICE
Copyright 1995-1996 Systems. rights reserved. part this document reproduced without prior written consent Systems. software described this document furnished under license only used copied accordance with terms such license.
DISCLAIMER
information this document subject change without notice does represent commitment part Systems. While information contained herein assumed accurate, Systems assumes responsibility errors omissions. event shall Systems, employees, contractors, authors this document liable special, direct, indirect, consequential damage, losses, costs, charges, claims, demands, claim lost profits, fees, expenses nature kind.
TRADEMARKS
C-SPY trademark Systems. Windows MS-DOS trademarks Microsoft Corp. other product names trademarks registered trademarks their respective owners. First edition: September 1996 Part ICC430-1 This documentation produced Human-Computer Interface.
PREFACE
WELCOME
Welcome MSP430 Compiler Programming Guide. This guide provides reference information about Systems Compiler MSP430 microprocessor. Before reading this guide recommend refer QuickStart Card, chapter Installation documentation route map, information about installing Systems tools overview documentation. using Embedded Workbench refer MSP430 Windows Workbench Interface Guide information about running Systems tools from Embedded Workbench interface, complete reference information about Embedded Workbench commands dialog boxes, Embedded Workbench editor. using command line version refer MSP430 Command Line Interface Guide general information about running Systems tools from command line, simple tutorial illustrate them. information about programming with MSP430 Assembler refer MSP430 Assembler, Linker, Librarian Programming Guide. your product includes optional MSP430 C-SPY debugger refer MSP430 C-SPY User Guide information about debugging with C-SPY.
ABOUT THIS GUIDE
This guide consists following chapters: Installation documentation route explains install Systems tools, gives overview documentation supplied with them. Introduction provides brief summary MSP430 Compiler's features. Tutorial illustrates might compiler develop series typical programs, illustrates some compiler's most important features. also describes typical development cycle using compiler. compiler options summary explains compiler options, gives summary them.
PREFACE
compiler options reference gives information about each compiler option. Configuration then describes configure compiler different requirements. Data representation describes compiler represents each data types gives recommendations efficient coding. General library definitions gives introduction library functions, summarizes them according header file. library functions reference then gives reference information about each library function. Language extensions summarizes extended keywords, #pragma keywords, predefined symbols, intrinsic functions specific MSP430 Compiler. Extended keyword reference then gives reference information about each extended keywords. #pragma directive reference gives reference information about #pragma keywords. Predefined symbols reference gives reference information about predefined symbols. Intrinsic function reference gives reference information about intrinsic functions. Assembly language interface describes interface between programs assembly language routines. Segment reference gives reference information about compiler's segments. ANSI language definitions describes differences between description language ANSI standard. Diagnostics lists compiler warning error messages.
PREFACE
ASSUMPTIONS
This guide assumes that already have working knowledge following: MSP430 processor. programming language. Windows, MS-DOS, UNIX, depending your host system.
This guide does attempt describe language itself. description language, Programming Language Kernighan Richie recommended, which latest edition also covers ANSI Note that illustrations this guide show Embedded Workbench running with Windows their appearance will slightly different using different platform.
CONVENTIONS
This guide uses following typographical conventions: Style
computer parameter [option]
Used Text that type that appears screen. label representing actual value should type part command. optional part command. Alternatives command. Names menus, menu commands, buttons, dialog boxes that appear screen. cross-reference another part this guide, another guide. Identifies instructions specific versions Systems tools Embedded Workbench interface. Identifies instructions specific command line versions Systems tools.
bold reference
this guide used abbreviation Programming Language Kernighan Richie.
PREFACE
CONTENTS
INSTALLATION DOCUMENTATION ROUTE Command line versions Windows Workbench versions UNIX versions Documentation route
INTRODUCTION compiler TUTORIAL Typical development cycle Getting started Creating program Using Adding interrupt handler
COMPILER OPTIONS SUMMARY Setting compiler options Options summary COMPILER OPTIONS REFERENCE Code generation Debug #define List #undef Include Command line CONFIGURATION Introduction XLINK command file Run-time library Memory Stack size Input output Register
CONTENTS
Heap size Initialization
DATA REPRESENTATION Data types Pointers Efficient coding GENERAL LIBRARY DEFINITIONS Introduction LIBRARY FUNCTIONS REFERENCE LANGUAGE EXTENSIONS Introduction Extended keywords summary #pragma directive summary Predefined symbols summary Intrinsic function summary Other extensions
EXTENDED KEYWORD REFERENCE #PRAGMA DIRECTIVE REFERENCE PREDEFINED SYMBOLS REFERENCE INTRINSIC FUNCTION REFERENCE ASSEMBLY LANGUAGE INTERFACE Creating shell Calling convention Calling assembly routines from SEGMENT REFERENCE ANSI LANGUAGE DEFINITIONS Introduction Definitions
viii
CONTENTS
DIAGNOSTICS Compilation error messages Compilation warning messages INDEX
CONTENTS
INSTALLATION
DOCUMENTATION ROUTE
This chapter explains install command line Windows Workbench versions products, gives overview user guides supplied with them. Please note that some products only exist command line version, that information differ slightly depending product platform using.
COMMAND LINE
VERSIONS
This section describes install command line versions Systems tools.
WHAT NEED
later. This product also compatible with window running under Windows Windows 3.51 later, Windows 3.1x. least Mbytes free disk space. minimum Mbytes available applications.
INSTALLATION
Insert first installation disk. MS-DOS prompt type:
a:\install
Follow instructions screen.
When installation complete: Make following changes your autoexec.bat file: paths Systems executable user interface files PATH variable; example:
INSTALLATION DOCUMENTATION ROUTE
Define environment variables C_INCLUDE XLINK_DFLTDIR specifying paths directories; example:
C_INCLUDE=c:\iar\inc\ XLINK_DFLTDIR=c:\iar\lib\
Reboot your computer changes take effect. Read Read-Me file, named product.doc, information included guides.
RUNNING TOOLS
Type appropriate command MS-DOS prompt. more information refer chapter Getting started Command Line Interface Guide.
WINDOWS This section explains install Embedded Workbench. WORKBENCH VERSIONS
WHAT NEED
Windows Windows 3.51 later, Windows 3.1x. Mbytes free disk space Embedded Workbench. minimum Mbytes applications.
using C-SPY should install Workbench before C-SPY.
INSTALLING FROM WINDOWS
Insert first installation disk. Click Start button taskbar, then click Settings Control Panel. Double-click Add/Remove Programs icon Control Panel folder. Click Install, then follow instructions screen.
RUNNING FROM WINDOWS
Click Start button taskbar, then click Programs Embedded Workbench. Click Embedded Workbench.
INSTALLATION DOCUMENTATION ROUTE
INSTALLING FROM WINDOWS 3.1x 3.51
Insert first installation disk. Double-click File Manager icon Main program group. Click disk icon File Manager toolbar. Double-click setup.exe icon, then follow instructions screen.
RUNNING FROM WINDOWS 3.1X 3.51
Program Manager double-click Embedded Workbench icon.
RUNNING C-SPY
Either: Choose Debugger from Embedded Workbench Project menu. Start C-SPY same start Embedded Workbench (see above).
UNIX VERSIONS
This section describes install UNIX versions Systems tools.
WHAT NEED
HP9000/700 workstation with HP-UX (minimum), 4/SPARC workstation with SunOS (minimum) Solaris (minimum).
INSTALLATION
Follow instructions provided with media.
RUNNING TOOLS
Type appropriate command UNIX prompt. more information refer chapter Getting started Command Line Interface Guide.
INSTALLATION DOCUMENTATION ROUTE
DOCUMENTATION
ROUTE
WINDOWS WORKBENCH
VERSION
COMMAND LINE
VERSION
QuickStart Card install tools Embedded Workbench.
QuickStart Card install tools UNIX versions.
Windows Workbench Interface Guide started with using Embedded Workbench, Embedded Workbench reference.
Command Line Interface Guide Utilities Guide started with using command line, information about environment variables utilities.
delete this story. there index entries here. route documentation route
Compiler Programming Guide learn about writing programs with Systems Compiler, reference information about compiler options language.
Assembler, Linker, Librarian Programming Guide learn about using Systems assembler, linker, librarian, reference information about these tools.
C-SPY User Guide, Windows Workbench Version learn about debugging with C-SPY Windows, C-SPY reference.
C-SPY User Guide, Command Line Version learn about debugging with command line version C-SPY, C-SPY reference.
INTRODUCTION
Systems MSP430 compiler available versions: command line version, Windows version integrated with Systems Embedded Workbench development environment. This guide describes both versions compiler, provides information about running from Embedded Workbench from command line, appropriate.
COMPILER
Systems Compiler MSP430 microprocessor offers standard features language, plus many extensions designed take advantage MSP430-specific facilities. compiler supplied with Systems Assembler MSP430, with which integrated, shares linker librarian manager tools. provides following features:
LANGUAGE FACILITIES
Conformance ANSI specification. Standard library functions applicable embedded systems, with source optionally available. IEEE-compatible floating-point arithmetic. Powerful extensions MSP430-specific features, including efficient I/O. Linkage user code with assembly routines. Long identifiers significant characters. 32000 external symbols.
PERFORMANCE
Fast compilation. Memory-based design which avoids temporary files overlays. Rigorous type checking compile time. Rigorous module interface type checking link time.
INTRODUCTION
LINT-like checking program source.
CODE GENERATION
Selectable optimization code speed size. Comprehensive output options, including relocatable binary, ASM, ASM+C, XREF, etc. Easy-to-understand error warning messages. Compatibility with C-SPY high-level debugger.
TARGET SUPPORT
Flexible variable allocation. Interrupt functions requiring assembly language. #pragma directive maintain portability while using processorspecific extensions.
TUTORIAL
This chapter illustrates might MSP430 Compiler develop series typical programs, illustrates some compiler's most important features: Before reading this chapter should: Have installed compiler software; QuickStart Card chapter Installation documentation route map. familiar with architecture instruction MSP430 processor. more information manufacturer's data book.
also recommended that complete introductory tutorial MSP430 Windows Workbench Interface Guide MSP430 Command Line Interface Guide, appropriate, familiarize yourself with interface using. Summary tutorial files following table summarizes tutorial files used this chapter: File
tutor1 tutor2 tutor3
What demonstrates Compiling running simple program. Using I/O. Interrupt handling.
RUNNING EXAMPLE PROGRAMS
This tutorial shows example programs using optional C-SPY simulator. also examples target system with EPROM emulator debugger. this case will first need configure routines. Alternatively, still follow this tutorial examining list files created. .lst .map files show which areas memory monitor.
TUTORIAL
TYPICAL
DEVELOPMENT CYCLE
Development will normally follow cycle illustrated below:
Start
Edit source file
Compile file
Link object files with debug option
Debug with C-SPY Compile file
Errors?
Link object files without debug options
code into PROM
following tutorial follows this cycle.
TUTORIAL
GETTING STARTED
first step developing project using compiler decide appropriate configuration suit your target system.
CONFIGURING SUIT TARGET SYSTEM
Each project needs XLINK command file containing details target system's memory map. Choosing linker command file suitable linker command file lnk430.xcl provided icc430 subdirectory. Examine lnk430.xcl using suitable text editor, such Embedded Workbench editor MS-DOS edit editor. file first contains following XLINK command define type MSP430:
-cmsp430
then contains series commands define segments used compiler. segments follows: Segment type
DATA CODE
Segment names
IDATA0, UDATA0, ECSTR, CSTACK RCODE, CODE, CDATA0, CONST, CSTR, CCSTR INTVEC
Address range
0x0200 0x7FFF 0x8000 0xFFDF
CODE
0xFFE0 0xFFFF
more information refer chapter Segment reference. file defines routines used printf scanf. Finally contains following line load appropriate library:
cl430
Run-time library, page details different libraries provided. Note that these definitions permanent: they altered later suit your project original choice proves incorrect, less than optimal.
TUTORIAL
detailed information configuring suit target memory, Memory map, page detailed information choosing stack size, Stack size, page
CREATING PROJECT
first step create project tutorial programs. Creating project using Embedded Workbench First, Embedded Workbench, create project tutorial follows. Choose from File menu display following dialog box:
Select Project choose display Project dialog box. Enter Tutorials Project Filename box, Target Family MSP430:
Then choose create project.
TUTORIAL
Project window will displayed. necessary, select Release from Targets drop-down list display Release target:
Next, create group contain tutorial source files follows. Choose Group. from Project menu enter name Common Sources. default both targets selected, group will added both targets:
Choose create group. will displayed Project window. Creating project using command line good idea keep files particular project directory, separate from other projects system files. tutorial files installed icc430 directory. Select this directory entering command:
c:\iar\icc430
During this tutorial will work this directory, that files create will reside here.
TUTORIAL
CREATING PROGRAM
first tutorial demonstrates compile, link, program.
ENTERING PROGRAM
first program simple program using only standard facilities. repeatedly calls function that increments variable:
#include <stdio.h> call_count; unsigned char my_char; const char con_char='a'; void do_foreground_process(void) call_count++; putchar(my_char); void main(void) my_int=0; call_count=0; my_char=con_char; while (my_int<100) do_foreground_process(); my_int++;
Writing program using Embedded Workbench Choose from File menu display dialog box. Select Source/Text choose open text document. Enter program given above save file tutor1.c. Alternatively, copy program provided compiler files directory. Writing program using command line Enter program using standard text editor, such MS-DOS edit editor, save file called tutor1.c. Alternatively, copy provided compiler files directory.
TUTORIAL
have source file which ready compile.
COMPILING PROGRAM
Compiling program using Embedded Workbench compile program first Tutorials project follows. Choose Files. from Project menu display Project Files dialog box. Locate file tutor1.c file selection list upper half dialog box, choose Common Sources group:
Then click Done close Project Files dialog box. Click display: symbol display file Project window tree
TUTORIAL
Then compiler options project follows: Select Release folder icon Project window, choose Options. from Project menu, select ICC430 Category list display compiler options pages:
Make sure that following options selected appropriate pages Options dialog box: Page Code generation Debug List Options Enable language extensions Generate debug information List file Insert mnemonics
When have made these changes choose options have specified.
TUTORIAL
compile file select Project window choose Compile from Project menu. progress will displayed Messages window:
listing created file tutor.lst. Open this choosing Open. from File menu, choosing tutor1.lst from release\list directory. Compiling program from command line compile program enter command:
icc430 tutor1 -I\iar\inc
There several compile options used here: Option
Description Allows code debugged with C-SPY. Creates list file. Includes assembler code with listing. Specifies pathname include files.
This creates object module called tutor1.r43 list file called tutor1.lst.
TUTORIAL
Viewing listing Examine list file produced variables assigned different segments.
MSP430 C-Compiler Vx.xx Front Vx.xx Global Optimizer Vx.xx Copyright Systems 1996 Source file List file Object file Command line tutor1.c tutor1.lst tutor1.r43 tutor1 -I\iar\inc
0004 0000 void do_foreground_process(void) call_count++; 92530000 5C420200 MOV.B #1,&call_count &my_char,R12 putchar(my_char); 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 NAME RSEG RSEG RSEG PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC EXTERN EXTERN RSEG #include <stdio.h> call_count; unsigned char my_char; const char con_char='a'; tutor1(16) CODE(1) CONST(1) UDATA0(1) call_count con_char do_foreground_process main my_char putchar ?CL430_1_00_L08 CODE
do_foreground_process:
TUTORIAL
0008 000A 000E 0010
7CF3 B0120000 3041 main:
AND.B CALL
#-1,R12 #putchar
void main(void) 0010 0012 0014 0018 001C 001E 001E 0022 3A906400 0434 do_foreground_process(); 0024 0028 B0120000 my_int++; 1A53 002A 002C 002C 002E 3A41 3041 F93F ?0000: (?0001) #1,R10 CALL #do_foreground_process 0A12 0A43 82430000 D2420000 0200 ?0001: while (my_int<100) #100,R10 (?0000) PUSH my_int=0; call_count=0; MOV.B #0,&call_count &con_char,&my_char my_char=con_char; #0,R10
0000 0000 0000 0000 0000 0002 0002 0003 my_char:
RSEG con_char: RSEG call_count:
CONST UDATA0
TUTORIAL
0003
Errors: none Warnings: none Code size: Constant size: Static variable size:
LINKING PROGRAM
Linking program using Embedded Workbench First options XLINK Linker. Select Release folder icon Project window, choose Options. from Project menu, select XLINK Category list display XLINK options pages. Then click List display page list options. Select Generate linker listing Segment generate file tutor1.map.
Then choose save XLINK options.
TUTORIAL
link object file generate code that debugged choose Link from Project menu. progress will displayed Messages window:
result linking code file tutorial.dbg file tutorial.map. Linking program from command line link object file with appropriate library module produce code that executed C-SPY debugger, enter command:
xlink tutor1 lnk430 tutor1.map
option specifies your XLINK command file lnk430, option allows code debugged with C-SPY. creates file filename gives name file. result linking code file called aout.a43 file called
tutor1.map.
TUTORIAL
Viewing file Examine file segment definitions code were placed into their physical addresses. main points file shown following listing:
Target List file msp430 tutor1.map aout.d43 debug tutor1 lnk430.xcl (-cMSP430 CCSTR=8000-FFDF -Z(CODE)INTVEC=FFE0-FFFF CSTACK+200=0200-7FFF -e_small_write=_formatted_write -e_medium_read=_formatted_read cl430.r43) tutor1.map Universal Linker Vx.xx Copyright Systems 1996
Output file Output format Command line
Command line Equivalent command line.
Included file Commands included linker command file.
CROSS REFERENCE
Program entry Shows address program entry point.
Program entry 8030
Relocatable, from module CSTARTUP
MODULE
Module Information about each module that loaded part program.
TUTORIAL
File name Shows name file from which modules were linked. Module Type name. Segments module list segments specified module, with information about each segment. Entries Global symbols declared within segment.
FILE NAME tutor1.r43 PROGRAM MODULE, NAME tutor1 SEGMENTS MODULE ====================== CODE Relative segment, address 8000 802F ENTRIES do_foreground_process calls direct main calls direct LOCALS ?0001 ?0000 CONST Relative segment, address 80D2 80D2 ENTRIES con_char UDATA0 Relative segment, address 0200 0202 ENTRIES call_count my_char ADDRESS 0200 0202 MODULE referred referred ADDRESS 80D2 MODULE referred ADDRESS 801E 802C 8010 CSTARTUP ADDRESS 8000 MODULE referred
Next file
FILE NAME PROGRAM MODULE, NAME CSTARTUP SEGMENTS MODULE ====================== CODE Relative segment, address 8030 8071 -ECSTR Relative segment, address
TUTORIAL
CCSTR Relative segment, address -CDATA0 Relative segment, address -IDATA0 Relative segment, address -UDATA0 Relative segment, address -INTVEC Common segment, address FFE0 FFFF -CSTACK Relative segment, address -LIBRARY MODULE, NAME lowinit SEGMENTS MODULE ====================== CODE Relative segment, address 8072 8075 ENTRIES _low_level_init ADDRESS 8072 MODULE CSTARTUP
-LIBRARY MODULE, NAME ABSOLUTE ENTRIES ============== ?CL430_1_00_L08 ADDRESS ======= 0001 MODULE ============= tutor1 memcpy memset putchar
Next module Information about next module current file.
LIBRARY MODULE, NAME memcpy
TUTORIAL
SEGMENTS MODULE ====================== CODE Relative segment, address 8076 808F ENTRIES memcpy ADDRESS 8076 MODULE CSTARTUP
-LIBRARY MODULE, NAME memset SEGMENTS MODULE ====================== CODE Relative segment, address 8090 80A7 ENTRIES memset ADDRESS 8090 MODULE CSTARTUP
-LIBRARY MODULE, NAME putchar SEGMENTS MODULE ====================== CODE Relative segment, address 80A8 80CB ENTRIES putchar calls direct LOCALS _low_level_put ADDRESS 80A8 ADDRESS 80AE MODULE tutor1
-LIBRARY MODULE, NAME exit SEGMENTS MODULE ====================== CODE Relative segment, address 80CC 80D1 ENTRIES exit ?C_EXIT ADDRESS 80CC 80CC MODULE referred CSTARTUP
TUTORIAL
SEGMENTS DUMP ORDER
Segments dump order Lists segments that make program, order linked.
SEGMENT ======= RCODE CODE CDATA0 ZVECT CONST CSTR CCSTR INTVEC IDATA0 UDATA0 ECSTR WCSTR TEMP CSTACK 0204 0200 FFE0 80D2 8000 START ADDRESS ============= 0403 0203 FFFF 80D2 ADDRESS =========== 80D1 TYPE ==== ALIGN =====
CROSS REFERENCE
Errors: none Warnings: none
Notice that, although link file specified address segments, many segments were used. most important information about segments end, where their address range given. Several entry points were described that appear original code. entry ?C_EXIT from CSTARTUP module. putchar entry from library file.
TUTORIAL
RUNNING PROGRAM
Running program using Embedded Workbench program using C-SPY debugger choose Debugger from Project menu. C-SPY window will displayed. Choose Step from Execute menu, click Step button toolbar, display source Source window:
Watch window monitor value call_count follows. Choose Watch from Window menu, click Watch button Watch window toolbar:
Then type call_countR this variable Watch window. Choose Step from Execute menu step through program until line do_foreground_process(); reached, check value variable call_count Watch window. value should since variable been initialized incremented. Execute current line move next line loop. Examine
call_count again should display showing that variable been incremented do_foreground_process.
TUTORIAL
Running program from command line Execute following command:
cs430 aout
This loads simulator loads program. Type STEP press display program execute first command. Then display value call_count typing:
call_count
This will return answer Then continue executing lines program typing STEP pressing until line my_int++ highlighted. Check value call_count again should also wish simulate routine foreground_process command ISTEP instead STEP, press instead
USING
shall create program that uses processor's ports. resulting code will driver into 4MUX mode, then output digits. This code demonstrates using #pragma directive header files. following listing code. Enter into suitable text editor save tutor2.c. Alternatively, copy provided icc430 subdirectory:
This example demonstrates display digits method enable extended keywords #pragma language=extended include sfrb/sfrw definitions registers #include "io310.h" char digit[10] 0xB7, segments a+b+c+d+e+f 0x12,
TUTORIAL
0x8F, 0x1F, 0x3A, 0x3D, 0xBD, 0x13, 0xBF, 0x3F
void main(void) Initialize driver (4Mux mode) LCDCTL 0xFF; display "6543210" (i=0; i<7; ++i) LCDMEM[i] digit[i];
first lines program are:
enable extended keywords #pragma language=extended
default, extended keywords available must include this directive before attempting any. #pragma directive described chapter #pragma directive reference. next lines code are:
include sfrb/sfrw definitions registers #include "io310.h"
file io310.h includes definitions registers processors.
TUTORIAL
COMPILING LINKING PROGRAM
Compiling linking program using Embedded Workbench Choose Files. from Project menu, Project Files dialog remove original tutor1.c file from Tutorials project tutor2.c instead. Then compile link project choosing Make from Project menu. Compiling linking program from command line Compile link program with standard link file follows:
icc430 tutor2 xlink tutor2 lnk430.xcl
RUNNING PROGRAM
Single-step through program using typing step. real target would possible attach display watch change. Using C-SPY only possible watch code execute.
ADDING
INTERRUPT HANDLER
shall modify previous program adding interrupt handler. MSP430 Compiler lets write interrupt handlers directly using interrupt keyword. interrupt will handle timer interrupt. This program sets timer interrupt once second outputs succession digits LCD. following listing interrupt code. code provided sample tutorials tutor3.c.
This example demonstrates basic timer Interrupt frequency enable extended keywords #pragma language=extended include definitions registers intrinsic functions (_EINT) #include "io310.h" #include "in430.h"
TUTORIAL
volatile clock;
count number basic timer interrupts
char digit[10] 0xB7, segments a+b+c+d+e+f 0x12, 0x8F, 0x1F, 0x3A, 0x3D, 0xBD, 0x13, 0xBF, 0x3F Basic Timer vector address 0xFFE2, offset INTVECT interrupt [0x02] void basic_timer(void) (++clock clock Display 1,2,3,.,9,0,1,2,. LCDMEM[0] digit[clock]; void main(void) Initialize driver (4Mux mode) LCDCTL 0xFF; Initialize Basic Timer Interrupt ACLK/256/128 BTCTL 0xF6; 0x80; Basic Timer Module Enable BTCTL &=~0x40; Disable Basic Timer Reset 0x80; Basic Timer Interrupt Enable clock Enable interrupts _EINT(); wait interrupt while (1);
TUTORIAL
intrinsic include file must present define _EINT function, include must present define MSP430 registers:
enable extended keywords #pragma language=extended include definitions registers intrinsic functions (_EINT) #include "io310.h" #include "in430.h"
interrupt function itself defined following lines:
interrupt [0x02] void basic_timer(void) (++clock clock Display 1,2,3,.,9,0,1,2,. LCDMEM[0] digit[clock];
interrupt keyword described chapter Extended keyword reference.
COMPILING LINKING PROGRAM
Compiling linking program using Embedded Workbench Compile link program before, adding Tutorials project choosing Make from Project menu. Compiling linking program from command line Compile link program before:
icc430 tutor3
VIEWING LISTING
From listing code produced compiler interrupt function:
0000 0000 0000 0000 0000 NAME RSEG COMMON RSEG RSEG tutor3(16) CODE(1) INTVEC(1) UDATA0(1) IDATA0(1)
TUTORIAL
0000 0000 0000 0000 0000 0000 0000 0000 0000
RSEG PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC EXTERN RSEG basic_timer:
CDATA0(1) LCD_Mem basic_timer clock digit main ?CL430_1_00_L08 CODE
This example demonstrates basic timer Interrupt frequency
enable extended keywords #pragma language=extended include definitions registers intinsic functions (_EINT) #include "io310.h" #include "in430.h" volatile clock; interrupts char digit[10] 0xB7, 0x12, 0x8F, 0x1F, 0x3A, 0x3D, 0xBD, 0x13, 0xBF, 0x3F Basic Timer vector address 0xFFE2, offset INTVECT interrupt [0x02] void basic_timer(void) segments a+b+c+d+e+f count number basic timer
TUTORIAL
0036 003A 0100 0030 0034 4000 002A 002E 0500 0024 0028 4000 0020 001C 001E 0020 3C41 0013 0012 0016 001A 000E 0012 0002 0006 000A 000C 0000 0C12
PUSH (++clock 92530000 B2900A00 0000 0220 82430000 ?0001: Display 1,2,3,.,9,0,1,2,. LCDMEM[0] digit[clock]; 1C420000 D24C0200 3100 RETI main: MOV.B &clock,R12 digit(R12),&49 clock #0,&clock (?0001) #1,&clock #10,&clock
void main(void) Initialize driver (4Mux mode) LCDCTL 0xFF; F2433000 MOV.B #255,&48 Initialize Basic Timer Interrupt ACLK/256/128
BTCTL F240F600 F2D08000
0xF6; MOV.B #246,&64
0x80; Basic Timer Module Enable BIS.B #128,&5
BTCTL &=~0x40; Disable Basic Timer Reset F2F0BF00 F2D08000 AND.B #191,&64
0x80; Basic Timer Interrupt Enable BIS.B #128,&1
TUTORIAL
0000 0002 0002 0000 0000 0002 0000 0000 0002 0002 000C 0000 0000 0002 0003 0004 0005 0006 0007 0008 0009 000A 000B 000C 3100 0000 0042 FF3F 0040 0042 32D2 003C
clock 82430000 _EINT(); EINT ?0003: wait interrupt while (1); (?0003) #0,&clock Enable interrupts
COMMON RSEG clock: RSEG LCD_Mem: digit: RSEG
INTVEC basic_timer UDATA0 IDATA0 CDATA0
TUTORIAL
COMPILER OPTIONS
SUMMARY
This chapter gives summary compiler options, explains options from Embedded Workbench command line. options divided into following sections, corresponding pages ICC430 options Embedded Workbench version: Code generation Debug #define List #undef Include Target
Command line section provides information those options which only available command line version. full reference about each option refer following chapter, compiler options reference. These chapters following symbols: Style Used Identifies instructions specific versions Systems tools Embedded Workbench interface. Identifies instructions specific command line versions Systems tools.
COMPILER OPTIONS SUMMARY
SETTING
COMPILER OPTIONS
Setting compiler options Embedded Workbench compiler options Embedded Workbench choose Options. from Project menu, select ICC430 Category list display compiler options pages:
Then click corresponding category options want view change. Setting compiler options from command line compiler options include them command line after icc430 command, either before after source filename. example, when compiling source prog, generate listing default listing filename (prog.lst):
icc430 prog
Some options accept filename, included after option letter with separating space. example, generate listing file list.lst:
icc430 prog list.lst
Some other options accept string that filename. This included after option letter, without space. example, generate listing default filename subdirectory list:
icc430 prog -Llist
COMPILER OPTIONS SUMMARY
Generally, order options command line, both relative each other source filename, significant. exception that order which more options used significant. Options also specified QCC430 environment variable. compiler automatically appends value this variable every command line, provides convenient method specifying options that required every compilation.
OPTIONS SUMMARY
following summary compiler options. full description option, under option's category name next chapter, compiler options reference. Option
-Aprefix filename -Dsymb [=xx] -ffilename -Hname -Iprefix
Description Assembly output prefixed filename. Assembly output named file. Make object library module. Nested comments. Char signed char. Defined symbols. Enable language extensions. Form-feed after function. Extend command line. Open standard input source. Global strict type check. Flag old-style functions. type info object code. object module name. Include paths. #include file lines.
comments.
Section List List Command line Code generation Code generation #define Code generation List Command line Command line Code generation Code generation Code generation Command line Include List Code generation
COMPILER OPTIONS SUMMARY
Option
-L[prefix] filename -Nprefix filename -Oprefix filename -pnn -Rname
Description List prefixed source name. List named file. Preprocessor prefixed filename. Preprocessor named file. object filename prefix. object filename. Lines/page. Insert mnemonics. Generate promable code. code segment name.
Section List List List List Command line Command line List List Command line Code generation Debug Command line Code generation List List #undef Code generation Code generation List List Code generation
-r[012][i][n][r] Generate debug information. -s[0-9] -Usymb -ur[4][5] -x[DFT2] -z[0-9]
silent operation. Optimize speed. Active lines only. spacing. Undefine symbol. ROM-monitor compatible code. Disable warnings. Explain declarations. Cross reference. Optimize size.
COMPILER OPTIONS
REFERENCE
This chapter gives detailed information each MSP430 Compiler options, divided into functional categories.
CODE GENERATION
code generation options determine interpretation source program generation object code. Embedded Workbench
Command line
Enable language extensions. `char' `signed char'. Writable strings, constants. `//' comments. Nested comments. Disable warnings. Make LIBRARY module. Global strict type checking. Flag old-style functions. type info object code.
COMPILER OPTIONS REFERENCE
-z[0-9] -s[0-9] -Rname -ur[4][5]
Optimize size. Optimize speed. Code segment. ROM-monitor compatible code.
ENABLE LANGUAGE EXTENSIONS (-e)
Syntax:
Enables target dependent extensions language. Normally, language extensions disabled preserve compatibility. using language extensions source, must enable them including this option. details language extensions, chapter Language extensions.
`CHAR' `SIGNED CHAR' (-c)
Syntax:
Makes char type equivalent signed char. Normally, compiler interprets char type unsigned char. make compiler interpret char type signed char instead, example compatibility with different compiler, this option. Note: run-time library compiled without Char signed char (-c) option, this option your program enable type checking with Global strict type check (-g) Generate debug information (-r) options, type mismatch warnings from linker.
WRITABLE STRINGS, CONSTANTS (-y)
Syntax:
Causes compiler compile string literals writable variables. Normally, string literals compiled read-only. want able write string literals, Writable strings, constants (-y) option, causing strings compiled writable variables. Note that arrays initialized with strings char "string") always compiled initialized variables, affected Writable strings, constants (-y) option.
COMPILER OPTIONS REFERENCE
`//' COMMENTS (-K)
Syntax:
Enables comments style, that comments introduced `//' extending line. Normally compatibility compiler does accept style comments. your source includes style comments, must `//' comments (-K) option them accepted.
NESTED COMMENTS (-C)
Syntax:
Enables nested comments. Normally, compiler treats nested comments fault issues warning when encounters one, resulting example from failure close comment. want nested comments, example comment-out sections code that include comments, Nested comments (-C) option disable this warning.
DISABLE WARNINGS (-w)
Syntax:
Disables compiler warning messages. Normally, compiler issues standard warning messages, additional warning messages enabled with Global strict type check (-g) option. disable warning messages, Disable warnings (-w) option.
MAKE LIBRARY MODULE (-b)
Syntax:
Causes object file library module rather than program module. compiler normally produces program module ready linking with XLINK. instead want library module inclusion library with XLIB, Make LIBRARY module (-b) option.
COMPILER OPTIONS REFERENCE
GLOBAL STRICT TYPE CHECKING (-g)
Syntax:
-g[A][O]
Enable checking type information throughout source. There class conditions source that indicate possible programming faults which compatibility compiler linker normally ignore. cause compiler linker issue warning each time they encounter such condition, Global strict type checking (-g) option.
FLAG OLD-STYLE FUNCTIONS (-gA)
Syntax:
Normally, Global strict type checking (-g) option does warn old-style functions. enable such warnings, Flag oldstyle functions (-gA) option.
TYPE INFO OBJECT CODE (-g0)
Syntax:
Normally, Global strict type checking (-g) option includes type information object module, increasing size link time, allowing linker issue type check warnings. exclude this information, avoiding this increase size link time inhibiting linker type check warnings, type info object code (-g0) option. When linking multiple modules, note that objects module compiled without type information, that without option with option with modifier, considered typeless. Hence there will never warning type mismatch from declaration from module compiled without type information, even module with corresponding declaration been compiled with type information. conditions checked Global strict type checking (-g) option are: Calls undeclared functions. Undeclared formal parameters. Missing return values non-void functions.
COMPILER OPTIONS REFERENCE
Unreferenced local formal parameters. Unreferenced goto labels. Unreachable code. Unmatching varying parameters functions.
#undef unknown symbols.
Valid ambiguous initializers. Constant array indexing range.
Examples following examples illustrate each these types error. Calls undeclared functions Program:
void my_fun(void) main(void) my_func(); mis-spelt my_fun gives undeclared function warning return
Error:
my_func(); mis-spelt my_fun gives undeclared function warning
"undecfn.c",5 Warning[23]: Undeclared function 'my_func'; assumed "extern" "int"
Undeclared formal parameters Program:
my_fun(parameter) return parameter+1; type parameter declared
Error:
my_fun(parameter) type parameter declared
COMPILER OPTIONS REFERENCE
"undecfp.c",1 Warning[9]: Undeclared function parameter 'parameter'; assumed "int"
Missing return values non-void functions Program:
my_fun(void) function body
Error:
"noreturn.c",4 Warning[22]: Non-void function: explicit "return" <expression>; expected
Unreferenced local formal parameters Program:
void my_fun(int parameter) localvar; unreferenced local variable exit without reference either variable unreferenced formal parameter
Error:
"unrefpar.c",6 Warning[33]: Local formal 'localvar' never referenced "unrefpar.c",6 Warning[33]: Local formal 'parameter' never referenced
Unreferenced goto labels Program:
main(void) function body exit:
unreferenced label
COMPILER OPTIONS REFERENCE
return
Error:
"unreflab.c",7
Warning[13]: Unreferenced label 'exit'
Unreachable code Program:
#include <stdio.h> main(void) goto exit; puts("This code unreachable"); exit: return
Error:
puts("This code unreachable"); "unreach.c",7 Warning[20]: Unreachable statement(s)
Unmatching varying parameters functions Program:
my_fun(len,str) len; char *str; str[0]='a' return len; char buffer[99] main(void) my_fun(buffer,99) my_fun(99) return
wrong order parameters missing parameter
COMPILER OPTIONS REFERENCE
Error:
my_fun(buffer,99) wrong order parameters "varyparm.c",14 Warning[26]: Inconsistent function changing type parameter my_fun(buffer,99) wrong order parameters "varyparm.c",14 Warning[26]: Inconsistent function changing type parameter my_fun(99) missing parameter "varyparm.c",15 Warning[25]: Inconsistent function varying number parameters
#undef unknown symbols Program:
#define my_macro Misspelt name gives warning that symbol unknown #undef my_macor main(void) return
Error:
#undef my_macor "hundef.c",4 Warning[2]: Macro 'my_macor' already #undef
Valid ambiguous initializers Program:
typedef struct {int f2;} type1; typedef struct {int type1 type1 f5;} type2; typedef struct {int type2 f8;} type3; type3 example {99, {42,1,2}, 37};
COMPILER OPTIONS REFERENCE
Error:
type3 example {99, {42,1,2}, "ambigini.c",4 Warning[12]: Incompletely bracketed initializer
Constant array indexing range Program:
char buffer[99] main(void) buffer[500] return
Constant index range
Error:
buffer[500] Constant index range "arrindex.c",5 Warning[28]: Constant [index] outside array bounds
OPTIMIZE SIZE (-z)
Syntax:
-z[0-9]
Causes compiler optimize code minimum size. Normally, compiler optimizes minimum size level (see below). change level optimization minimum size using option follows: Modifier
Level optimization. Fully debuggable. Some constructs debuggable. Full optimization. Some constructs debuggable.
COMPILER OPTIONS REFERENCE
OPTIMIZE SPEED (-s)
Syntax:
-s[0-9]
Causes compiler optimize code maximum execution speed. Normally, compiler optimizes maximum execution speed level (see below). change level optimization maximum execution speed using option follows: Modifier
Level optimization. Fully debuggable. Some constructs debuggable. Full optimization. Some constructs debuggable.
CODE SEGMENT (-R)
Syntax:
-Rname
Sets name code segment. Normally, compiler places executable code segment named CODE which, default, linker places variable address. want able specify explicit address code, option specify special code segment name which then assign fixed address linker command file.
ROM-MONITOR COMPATIBLE CODE (-ur)
Syntax:
-ur[4][5]
Causes compiler generate ROM-monitor compatible code using register and/or
COMPILER OPTIONS REFERENCE
DEBUG
Debug options determine level debugging information included object code. Embedded Workbench
Command line
-r[012][i][n][r]
Generate debug information.
GENERATE DEBUG INFORMATION (-r)
Syntax:
-r[012][i][n][r]
Causes compiler include additional information required C-SPY other symbolic debuggers object modules. Normally compiler does include debugging information, code efficiency. make code debuggable with C-SPY, simply include option with modifiers. make code debuggable with other debuggers, select more options, follows: Option #include file information. Suppress source object code. register variables. Code added statements. Command line
COMPILER OPTIONS REFERENCE
Normally Generate debug information (-r) option does include #include file debugging information, because this usually little interest, most debuggers other than C-SPY support debugging inside #include files well. want debug inside #include files, example #include files contain function definitions rather than more usual function declarations, #include file information (-ri) modifier. side effect that source line records contain global (=total) line count which affect source line displays some debuggers other than C-SPY. Generate debug information (-r) option usually includes source lines object file, they displayed during debugging. want suppress this reduce size object file, Suppress source object code (-rn) modifier. this option most other debuggers that include specific information about Systems compilers. Normally, compiler tries locals register variables. However, some debuggers cannot handle register variables; suppress register variables register variables (-rr) modifier. Code added statements options (-r1) (-r2) NOPs code generated each statement. Only these options your debugging tool specifically requires
#define
#define option allows define symbols compiler. Embedded Workbench
COMPILER OPTIONS REFERENCE
Command line
Defined symbols.
DEFINED SYMBOLS (-D)
Syntax:
-Dsymb[=xx]
Defines symbol with name symb value value specified, used. Defined symbols (-D) same effect #define statement source file.
-Dsymb equivalent #define symb
Defined symbols (-D) option useful specifying value choice that would otherwise specified source file more conveniently command line. example, could arrange your source produce either test production version your program depending whether symbol testver defined. this would include sections such
testver test version only #endif #ifdef additional code lines
Then, would select version required command line follows: production version: icc430 prog test version:
icc430 prog -Dtestver
COMPILER OPTIONS REFERENCE
LIST
List options determine whether listing produced, information included listing. Embedded Workbench
Command line
-L[prefix] filename -pnn -x[DFT2] -Aprefix filename -Nprefix filename
List prefixed source name. List named file. Insert mnemonics. #include file text. Active lines only. Form feed after function. Lines/page. spacing. Cross reference. Assembly output prefixed filename. Assembly output named file. Preprocessor prefixed filename. Preprocessor named file. Explain declarations.
COMPILER OPTIONS REFERENCE
LIST FILE
List prefixed source name (-L) Syntax: -L[prefix] Generate listing file with same name source with extension .lst, prefixed argument any. Normally, compiler does generate listing. simply generate listing, option without prefix. example, generate listing file prog.lst, use:
icc430 prog
generate listing different directory, option followed directory name. example, generate listing corresponding filename directory \list:
icc430 prog -Llist\
This sends file list\prog.lst rather than default prog.lst.
used same time
List named file (-l) Syntax: filename Generates listing named file with default extension .lst. Normally, compiler does generate listing. generate listing named file, option. example, generate listing file list.lst, use:
icc430 prog list
More often need specify particular filename, which case option instead. This option used same time option.
INSERT MNEMONICS (-q)
Syntax:
Includes generated assembly lines listing. Normally, compiler does include generated assembly lines listing. want these included, example able check efficiency code generated particular statement, Insert mnemonics (-q) option.
COMPILER OPTIONS REFERENCE
Note that this option only available listing specified. also options
#INCLUDE FILE TEXT (-i)
Syntax:
Causes listing include #include files. Normally listing does include #include files, since they usually contain only header information that would waste space listing. include #include files, example because they include function definitions preprocessed lines, include #include file text (-i) option.
ACTIVE LINES ONLY (-T)
Syntax:
Causes compiler list only active source lines. Normally compiler lists source lines. save listing space eliminating inactive lines, such those false structures, Active lines only (-T) option.
FORM-FEED AFTER FUNCTION (-F)
Syntax:
Generates form-feed after each listed function assembly listing. Normally, listing simply starts each function next line. cause each function appear page, would include this option. Form-feeds never generated functions that listed, example, #include files.
LINES/PAGE (-p)
Syntax:
-pnn
Causes listing formatted into pages, specifies number lines page range 150.
COMPILER OPTIONS REFERENCE
Normally, listing formatted into pages. format into pages with form feed every page, Lines/page (-p) option. example, printer with lines page:
icc430 prog -p50
SPACING (-t)
Syntax:
number character positions stop which must range Normally, listing formatted with spacing characters. want different spacing, with spacing (-t) option.
CROSS REFERENCE (-x)
Syntax:
-x[DFT2]
Includes cross-reference list listing. Normally, compiler does include global symbols listing. include listing list variable objects, functions, #define statements, enum statements, typedef statements that referenced, Cross reference (-x) option with modifiers. When select Cross reference following options become available: Command line
Option Show unreferenced #defines. Show unreferenced functions. Show unreferenced typedefs enum constants. Dual line spacing.
COMPILER OPTIONS REFERENCE
ASSEMBLY OUTPUT FILE
Assembly output prefixed filename (-A) Syntax: -Aprefix Generates assembler source prefix source.s43. default compiler does generate assembler source. send assembler source file with same name source leafname with extension .s43, without argument. example:
icc430 prog
generates assembly source file prog.s43. send assembler source same filename different directory, option with directory argument. example:
icc430 prog -Aasm\
generates assembly source file asm\prog.s43. assembler source assembled appropriate assembler. option also used, source lines included assembly source file comments. option used same time option. Assembly output named file (-a) Syntax: filename Generates assembler source filename.s43. default compiler does generate assembler source. This option generates assembler source named file. filename consists leafname optionally preceded pathname optionally followed extension. extension given, target-specific assembler source extension used. assembler source assembled appropriate Assembler. option also used, source lines included assembly source file comments. This option used same time
COMPILER OPTIONS REFERENCE
PREPROCESSOR PREFIXED FILENAME (-N)
Syntax:
-Nprefix
Generates preprocessor output prefix source.i. default compiler does generate preprocessor output. send preprocessor output file with same name source leafname with extension without argument. example:
icc430 prog
generates preprocessor output file prog.i. send preprocessor output same filename different directory, option with directory argument. example:
icc430 prog -Npreproc\
generates assembly source file preproc\prog.i. option used same time option.
PREPROCESSOR NAMED FILE (-n)
Syntax:
filename
Generates preprocessor output filename.i. default compiler does generate preprocessor output. This option generates preprocessor output named file. filename consists leafname optionally preceded pathname optionally followed extension. extension given, extension used. This option used same time
EXPLAIN DECLARATIONS (-X)
Syntax:
Displays English description each declaration file. obtain English descriptions declarations, example investigation error messages, List declarations (-X) option.
COMPILER OPTIONS REFERENCE
example, declaration:
void signal(int _sig, void func) ())) (int);
gives description:
storage class: extern [func_attr:0210] prototyped ?cptr0 function returning [attribute:0110] ?dptr0 ?cptr0 code pointer [func_attr:0210] prototyped ?cptr0 function returning [attribute:0110] ?dptr0 void having following parameter(s): storage class auto [attribute:0110] ?dptr0 having following parameter(s): storage class: auto [attribute:0110] ?dptr0 storage class auto [attribute:0110] ?dptr0 ?cptr0 code pointer [func_attr:0210] ?cptr0 function returning [attribute:0110] ?dptr0 void
#undef
#undef option allows undefine predefined symbols. Embedded Workbench
Command line
-Usymb
Predefined symbols.
COMPILER OPTIONS REFERENCE
PREDEFINED SYMBOLS (-U)
Syntax:
-Usymb
Removes definition named symbol. Normally, compiler provides various pre-defined symbols. want remove these, example avoid conflict with symbol your with same name, Predefined symbols (-U) option. list predefined symbols, chapter Predefined symbols reference. undefine symbol, deselect Predefined symbols list.
example, remove symbol _VER_, use:
icc430 prog -U_VER_
INCLUDE
Include option allows define include path compiler. Embedded Workbench
Command line
-Iprefix
Include paths.
COMPILER OPTIONS REFERENCE
INCLUDE PATHS (-I)
Syntax:
-Iprefix
Adds prefix list #include file prefixes. Normally, compiler searches include files only source directory filename enclosed quotes opposed angle brackets), C_INCLUDE paths, finally current directory. have placed #include files some other directory, must Include paths (-I) option inform compiler that directory. example:
icc430 prog -I\mylib\
Note that compiler simply adds prefix onto start include filename, important include final backslash necessary. There limit number options allowed single command line. When many options used, avoid command line exceeding operating system's limit, would command file; option. Note: full description compiler's #include file search procedure follows: When compiler encounters include file name angle brackets such
#include <stdio.h>
performs following search sequence: filename prefixed each successive prefix. filename prefixed each successive path C_INCLUDE environment variable any. filename alone.
When compiler encounters include file name double quotes such
#include "vars.h"
searches filename prefixed source file path, then performs sequence angle-bracketed filenames.
COMPILER OPTIONS REFERENCE
COMMAND LINE
following additional options available from command line.
-ffilename -Hname -Oprefix filename
Extend command line. Open standard input source. object module name. object filename prefix. object filename. Generate PROMable code. silent operation.
EXTEND COMMAND LINE (-f)
Syntax:
-ffilename
Reads command line options from named file, with default extension .xcl. Normally, compiler accepts command parameters only from command line itself QCC430 environment variable. make long command lines more manageable, avoid operating system command line length limit, option specify command file, from which compiler reads command line items they been entered position option. command file, format items exactly they were command line itself, except that multiple lines since newline character acts just space character. example, could replace command line:
icc430 prog -Dtestver "-Dusername=John Smith" -Duserid=463760
with
icc430 prog -Dtestver userinfo
file userinfo.xcl containing:
"-Dusername=John Smith" -Duserid=463760
COMPILER OPTIONS REFERENCE
OPEN STANDARD INPUT SOURCE (-G)
Syntax:
Opens standard input source, instead reading source from file. Normally, compiler reads source from file named command line. wish read source instead from standard input (normally keyboard), option omit source filename. source filename stdin.c.
OBJECT MODULE NAME (-H)
Syntax:
-Hname
Normally, internal name object module name source file, without directory name extension. object module name explicitly, option, example:
icc430 prog -Hmain
This particularly useful when several modules have same filename, since normally resulting duplicate module name would cause linker error. example when source file temporary file generated preprocessor. following which operating system variable containing name source file) will give duplicate name errors from linker:
preproc %1.c temp.c icc430 temp.c preprocess source, generating temp.c module name always 'temp'
avoid this, retain original name:
preproc %1.c temp.c icc430 temp.c -H%1 preprocess source, generating temp.c original source name module name
OBJECT FILENAME PREFIX (-O)
Syntax:
-Oprefix
Sets prefix used filename object.
COMPILER OPTIONS REFERENCE
Normally (and unless option used) object stored with filename corresponding source filename, with extension .r43. store object different directory, option. example, store object \obj directory, use:
icc430 prog -O\obj\
option used same time option.
OBJECT FILENAME (-o)
Syntax:
filename
filename which object module will stored. filename consists optional pathname, obligatory leafname, optional extension (default .r43). Normally compiler stores object code file whose name prefix specified plus leafname source, plus extension .r43.
store object different filename, option. example, store file obj.r43, would use:
icc430 prog
instead want store object with corresponding filename different directory, option. option used same time option.
GENERATE PROMABLE CODE (-P)
Syntax:
Causes compiler generate code suitable running read-only memory (PROM). This option included compatibility with other compilers, MSP430 Compiler always active.
COMPILER OPTIONS REFERENCE
SILENT OPERATION (-S)
Syntax:
Causes compiler operate without sending unnecessary messages standard output (normally screen). Normally compiler issues introductory messages final statistics report. inhibit this output, option. This does affect display error warning messages.
CONFIGURATION
This chapter describes configure compiler different requirements.
INTRODUCTION
Systems based MSP430 microprocessor vary considerably their requirements. Each feature environment usage handled more configurable elements compiler packages, follows: Feature Memory Non-volatile Stack size
putchar getchar functions printf/scanf facilities
Configurable element XLINK command file. XLINK command file. XLINK command file.
page
Run-time library module. XLINK command file. Heap library module.
_low_level_init
Heap size Hardware/memory initialization
module. following sections describe each above features. Note that many configuration procedures involve editing standard files, want make copies originals before beginning.
XLINK COMMAND FILE
create XLINK command file particular project should first copy file lnk430.xcl from c:\iar\icc430. should then modify this file, described within file, specify details target system's memory map.
CONFIGURATION
RUN-TIME LIBRARY
XLINK command file refers library file cl430.r43. This should normally changed.
MEMORY
need specify XLINK your hardware environment's address ranges RAM. would normally this your copy XLINK command file template. link options specify: areas: used functions, constants, initial values. areas: used stack variables.
details specifying memory address ranges, contents XLINK command file template XLINK section MSP430 Assembler, Linker, Librarian Programming Guide.
NON-VOLATILE
compiler supports declaration variables that reside non-volatile through no_init type modifier memory #pragma. compiler places such variables separate segment NO_INIT, which should assign address range nonvolatile hardware environment. run-time system does initialize these variables. assign NO_INIT segment address non-volatile RAM, need modify XLINK command file. details assigning segment given address, XLINK section MSP430 Assembler, Linker, Librarian Programming Guide.
STACK SIZE
compiler uses stack variety user program operations, required stack size depends heavily details these operations. given stack size small, stack will normally allowed overwrite variable storage resulting likely program failure. given stack size large, will wasted.
ESTIMATING REQUIRED STACK SIZE
stack used following:
Preserving register variables across function calls.
CONFIGURATION
Storing local variables parameters. Storing temporary results expressions. Storing temporary values run-time library routines. Saving return address function calls. Saving processor state during interrupts.
total required stack size worst case total required sizes each above.
CHANGING STACK SIZE
default stack size (200h) bytes linker command files, with expression CSTACK+200 linker command:
-Z(DATA)CSTACK+200
change stack size edit linker command file replace size stack want use.
INPUT OUTPUT
PUTCHAR GETCHAR
functions putchar getchar fundamental functions through which performs character-based I/O. characterbased available, must provide definitions these functions using whatever facilities hardware environment provides. starting-point creating routines files c:\iar\icc430\putchar.c c:\iar\icc430\getchar.c. Customizing putchar procedure creating customized version putchar follows: Make required additions source putchar.c, save back under same name create your routine using putchar.c model).
example, code below uses memory-mapped write display:
putchar(int outchar) very basic putchar routine must initialized must initialized character_map
CONFIGURATION
must with lookup table. will then display first characters supplied (pos>0)
Compile modified putchar using appropriate processor option.
icc430 putchar
This will create optimized replacement object module file named putchar.r43. putchar module appropriate run-time library module, replacing original. example, putchar module standard library, command:
xlib def-cpu MSP430 rep-mod putchar cl4308ss exit
library module cl430 will have modified putchar instead original. sure save your original cl430.r43 file before overwrite putchar module.) Note that XLINK allows test modified module before installing library using option. Place following lines into your .xcl link file:
putchar cl430
This causes your version putchar.r43 load instead cl430 library. MSP430 Assembler, Linker, Librarian Programming Guide. Note that putchar serves low-level part printf function. Customizing getchar low-level function getchar supplied files, getchar.c llget.c.
CONFIGURATION
PRINTF SPRINTF
printf sprintf functions common formatter called _formatted_write. ANSI standard version _formatted_write very large, provides facilities required many applications. reduce memory consumption following alternative smaller versions also provided standard library: _medium_write _formatted_write, except that floating-point numbers supported. attempt specifier will produce error:
FLOATS? wrong formatter installed! _medium_write considerably smaller than _formatted_write.
_small_write _medium_write, except that supports only specifiers objects, does support field width precision arguments. size _small_write 10-15% size _formatted_write. default version _small_write.
SELECTING WRITE FORMATTER VERSION
selection write formatter made XLINK control file. default selection, _small_write, made line:
-e_small_write=_formatted_write
select full ANSI version, remove this line. select _medium_write, replace this line with:
REDUCED PRINTF
many applications sprintf required, even printf with _small_write provides more facilities than justified memory consumed. Alternatively, custom output routine required support particular formatting needs and/or non-standard output devices.
CONFIGURATION
such applications, highly reduced version entire printf function (without sprintf) supplied source form file intwri.c. This file modified your requirements compiled module inserted into library place original using procedure described putchar above.
SCANF SSCANF
similar printf sprintf functions, scanf sscanf common formatter called _formatted_read. ANSI standard version _formatted_read very large, provides facilities that required many applications. reduce memory consumption, alternative smaller version also provided standard library. _medium_read _formatted_read, except that floating-point numbers supported. _medium_read considerably smaller than _formatted_read. default version _medium_read.
SELECTING READ FORMATTER VERSION
selection read formatter made XLINK control file. default selection, _medium_read, made line:
-e_medium_read=_formatted_read
select full ANSI version, remove this line.
REGISTER
program access MSP430 system using memorymapped internal special-function registers (SFRs). operators that apply integral types except unary (address) operator applied registers. Predefined sfrb/sfrw declarations MSP430 family supplied; Run-time library, page chapter Extended keyword reference.
CONFIGURATION
Predefined special function registers (SFRs) interrupt routines given following header files: Processor MSP430x31x MSP430x32x MSP430x33x Header file
io310.h io320.h io330.h
These files provided icc430 subdirectory.
HEAP SIZE
library functions malloc calloc used program, compiler creates heap memory from which their allocations made. default heap size 2000 bytes. procedure changing heap size described file
c:\iar\etc\heap.c.
test modified heap module including following lines .xcl link file:
heap cl430l
This will load your version heap.r43 instead cl430l library.
INITIALIZATION
processor reset, execution passes run-time system routine called CSTARTUP, which normally performs following: Initializes stack pointer. Initializes file-level static variables. Calls user program function main.
CSTARTUP also responsible receiving retaining control user program exits, whether through exit abort.
CONFIGURATION
VARIABLE INITIALIZATION
some applications want initialize registers, omit default initialization data segments performed CSTARTUP. this providing customized version routine _low_level_init, which called from CSTARTUP before data segments initialized. value returned _low_level_init determines whether data segments initialized. run-time library includes dummy version _low_level_init that simply returns cause CSTARTUP initialize data segments. source _low_level_init provided file lowinit.c, default located icc430 directory. perform your initializations, create version this routine containing necessary code initializations. also want disable initialization data segments, make routine return Compile customized routine link with rest your code.
MODIFYING CSTARTUP
want modify CSTARTUP itself will need reassemble CSTARTUP with options which match your selected compilation options. overall procedure assembling appropriate copy CSTARTUP follows: Make required modifications assembler source
CSTARTUP, supplied default file c:\iar\icc430\cstartup.s43, save under same name.
Assemble CSTARTUP.
This will create object module file named cstartup.r43. should then following commands linker command file make XLINK CSTARTUP module have defined instead library:
cstartup library
Embedded Workbench modified cstartup file your project, before library linker command file.
DATA REPRESENTATION
This chapter describes MSP430 Compiler represents each data types, gives recommendations efficient coding.
DATA TYPES
MSP430 Compiler supports ANSI basic elements. Variables stored with least significant part located memory address. following table gives size range each data type: Data type
sfrb, sfrw
Bytes
Range
Notes chapter Extended keyword reference.
char default) char (using option) signed char unsigned char short, unsigned short, unsigned long unsigned long pointer enum float
-128 -128 -215 215-1 -231 231-1 232-1
Equivalent
unsigned char
Equivalent signed
char
-32768 32767 65535 -2147483648 2147483647 4294967295 Pointers, page below.
1.18E-38 3.39E+38
DATA REPRESENTATION
Data type
double, long double
Bytes
Range
Notes
1.18E-38 3.39E+38 (same float)
ENUM TYPE
enum keyword creates each object with shortest integer type (char, short, int, long) required contain value.
CHAR TYPE
char type default, unsigned compiler, Char signed char (-c) option allows make signed. Note, however, that library compiled with char types unsigned.
FLOATING POINT
Floating-point values represented byte numbers standard IEEE format. Floating-point values below smallest limit will regarded zero, overflow gives undefined results. 4-byte floating-point format memory layout 4-byte floating-point numbers
Mantissa
Exponent
value number (-1)S 2(Exponent-127) 1.Mantissa Zero represented bytes zeros. precision float operators approximately decimal digits.
SPECIAL FUNCTION REGISTER VARIABLES
Special Function Register (sfr) variables located direct internal locations. sfrb instructions have range 0x00 0xFF sfrw from 0x100 0x1FF. sfrb type allows symbolic name associated with byte this range. register that address addressed symbolically, memory space allocated.
DATA REPRESENTATION
BITFIELDS
Bitfields expressions will have same data type base type (signed unsigned char, short, int, long). Bitfields with base type char, short, long extensions ANSI integer bitfields. Bitfield variables packed elements specified type starting position.
POINTERS
This section describes MSP430 Compiler's code pointers data pointers.
CODE POINTERS
size code pointers bytes refer memory range 0x0000 0xFFFF.
DATA POINTERS
size data pointers bytes, point memory range 0x0000 0xFFFF.
EFFICIENT CODING
important appreciate limitations MSP430 architecture order avoid inefficient language constructs. following list recommendations best MSP430 Compiler. Bitfield types should used only conserve data memory space they execute slowly MSP430. mask unsigned char unsigned instead bitfields. must bitfields, unsigned efficiency. Variables that used outside their module should declared static, this improves possibility temporarily keeping them register. unsigned data types, when possible. Sometimes unsigned operations execute more efficiently than signed counterparts. This especially applies division modulo.
DATA REPRESENTATION
ANSI prototypes. Function calls ANSI functions performed more efficiently than K&R-style functions; chapter ANSI language definitions. MSP430 operates most efficiently 16-bit data types short unsigned short). general, 8-bit data types saves data space, does reduce code size. 32-bit data types have direct support architecture therefore less efficient. Scalar auto variables normally allocated registers. Therefore autos rather than statics whenever possible. first parameters functions passed registers; Calling convention, page 182. thus more efficient pass arguments function parameters than static variables. Copying structs unions costly operations. Avoid run-time assignment structs/unions, functions with struct/union parameters, functions returning structs/unions. Prefer operating pointers structs/unions whenever possible. Non-scalar auto variables (structs, unions arrays) with initial values results run-time copying each time function, which they declared, called. constant variables, this could avoided using storage class "static const".
GENERAL LIBRARY
DEFINITIONS
This chapter gives introduction library functions, summarizes them according header file.
INTRODUCTION
Compiler package provides most important library definitions that apply PROM-based embedded systems. These three types: Standard library definitions, user programs. These documented this chapter.
CSTARTUP, single program module containing start-up code.
Intrinsic functions, allowing low-level MSP430 features.
LIBRARY OBJECT FILES
Most library definitions used without modification, that directly from library object files supplied. There some I/Ooriented routines (such putchar getchar) that need customize your target application. library object files supplied having been compiled with Flag old-style functions (-gA) option.
HEADER FILES
user program gains access library definitions through header files, which incorporates using #include directive. avoid wasting time compilation, definitions divided into number different header files each covering particular functional area, letting include just those that required. essential include appropriate header file before making reference definitions. Failure this cause call fail during execution, generate error warning messages compile time link time.
GENERAL LIBRARY DEFINITIONS
LIBRARY DEFINITIONS SUMMARY
This section lists header files summarizes functions included each. Header files additionally contain target-specific definitions these documented chapter Language extensions.
CHARACTER HANDLING ctype.h
isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper isalnum(int isalpha(int iscntrl(int isdigit(int isgraph(int islower(int isprint(int ispunct(int isspace(int isupper(int isxdigit(int tolower(int toupper(int
Letter digit equality. Letter equality. Control code equality. Digit equality. Printable non-space character equality. Lower case equality. Printable character equality. Punctuation character equality. White-space character equality. Upper case equality. digit equality. Converts lower case. Converts upper case.
LOW-LEVEL ROUTINES icclbutl.h
_formatted_read _formatted_read (const char **line, const char **format, va_list _formatted_write (const char* format, void outputf (char, void void *sp, va_list _formatted_read (const char **line, const char **format, va_list
Reads formatted data.
_formatted_write
Formats writes data.
_medium_read
Reads formatted data excluding floating-point numbers.
GENERAL LIBRARY DEFINITIONS
_medium_write
_formatted_write (const char* format, void outputf (char, void void *sp, va_list _formatted_write (const char* format, void outputf (char, void void *sp, va_list
Writes formatted data excluding floating-point numbers. Small formatted data write routine.
_small_write
MATHEMATICS math.h
acos asin atan atan2 ceil cosh fabs floor fmod frexp ldexp log10 modf double acos(double arg) double asin(double arg) double atan(double arg) double atan2(double arg1, double arg2) double ceil(double arg) double cos(double arg) double cosh(double arg) double exp(double arg) double fabs(double arg) double floor(double arg) double fmod(double arg1, double arg2) double frexp(double arg1, *arg2) double ldexp(double arg1, arg2) double log(double arg) double log10(double arg) double modf(double value, double *iptr)
cosine. sine. tangent. tangent with quadrant. Smallest integer greater than equal arg. Cosine. Hyperbolic cosine. Exponential. Double-precision floating-point absolute. Largest integer less than equal. Floating-point remainder. Splits floating-point number into parts. Multiply power two. Natural logarithm. Base-10 logarithm. Fractional integer parts.
GENERAL LIBRARY DEFINITIONS
sinh sqrt tanh
double pow(double arg1, double arg2) double sin(double arg) double sinh(double arg) double sqrt(double arg) double tan(double double tanh(double arg)
Raises power. Sine. Hyperbolic sine. Square root. Tangent. Hyperbolic tangent.
NON-LOCAL JUMPS setjmp.h
longjmp setjmp void longjmp(jmp_buf env, val) setjmp(jmp_buf env)
Long jump. Sets jump return point.
VARIABLE ARGUMENTS stdarg.h
va_arg va_end va_list va_start type va_arg(va_list mode) void va_end(va_list char *va_list[1] void va_start(va_list parmN)
Next argument function call. Ends reading function call arguments. Argument list type. Starts reading function call arguments.
INPUT/OUTPUT stdio.h
getchar gets printf putchar puts scanf getchar(void) char *gets(char printf(const char *format, putchar(int value) puts(const char scanf(const char *format,
Gets character. Gets string. Writes formatted data. Puts character. Puts string. Reads formatted data.
GENERAL LIBRARY DEFINITIONS
sprintf sscanf
sprintf(char const char *format,) sscanf(const char const char *format,
Writes formatted data string. Reads formatted data from string.
GENERAL UTILITIES stdlib.h
abort atof atoi atol bsearch void abort(void) abs(int double atof(const char *nptr) atoi(const char *nptr) long atol(const char *nptr) void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, (*compare) (const void *_key, const void *_base)); void *calloc(size_t nelem, size_t elsize) div_t div(int numer, denom) void exit(int status) void free(void *ptr) long labs(long ldiv_t ldiv(long numer, long denom) void *malloc(size_t size) void qsort(const void *base, size_t nmemb, size_t size, (*compare) (const void *_key, const void *_base)); rand(void)
Terminates program abnormally. Absolute value. Converts ASCII double. Converts ASCII int. Converts ASCII long int. Makes generic search array.
calloc exit free labs ldiv malloc qsort
Allocates memory array objects. Divide. Terminates program. Frees memory. Long absolute. Long division. Allocates memory. Makes generic sort array.
rand
Random number.
GENERAL LIBRARY DEFINITIONS
realloc srand strtod strtol
void *realloc(void *ptr, size_t size) void srand(unsigned seed) double strtod(const char *nptr, char **endptr) long strtol(const char *nptr, char **endptr, base) unsigned long strtoul (const char *nptr, char **endptr, base int)
Reallocates memory. Sets random number sequence. Converts string double. Converts string long integer.
strtoul
Converts string unsigned long integer.
STRING HANDLING string.h
memchr memcmp memcpy memmove memset strcat strchr strcmp strcoll strcpy void *memchr(const void size_t memcmp(const void *s1, const void *s2, size_t void *memcpy(void *s1, const void *s2, size_t void *memmove(void *s1, const void *s2, size_t void *memset(void size_t char *strcat(char *s1, const char *s2) char *strchr(const char strcmp(const char *s1, const char *s2) strcoll(const char *s1, const char *s2) char *strcpy(char *s1, const char *s2)
Searches character memory. Compares memory. Copies memory. Moves memory. Sets memory. Concatenates strings. Searches character string. Compares strings. Compares strings. Copies string.
GENERAL LIBRARY DEFINITIONS
strcspn strerror strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtok strxfrm
size_t strcspn(const char *s1, const char *s2) char *strerror(int errnum) size_t strlen(const char char *strncat(char *s1, const char *s2, size_t strncmp(const char *s1, const char *s2, size_t char *strncpy(char *s1, const char *s2, size_t char *strpbrk(const char *s1, const char *s2) char *strrchr(const char size_t strspn(const char *s1, const char *s2) char *strstr(const char *s1, const char *s2) char *strtok(char *s1, const char *s2) size_t strxfrm(char *s1, const char *s2, size_t
Spans excluded characters string. Gives error message string. String length. Concatenates specified number characters with string. Compares specified number characters with string. Copies specified number characters from string. Finds specified characters string. Finds character from right string. Spans characters string. Searches substring. Breaks string into tokens. Transforms string returns length.
COMMON DEFINITIONS stddef.h
functions (various definitions including size_t, NULL, ptrdiff_t, offsetof, etc).
INTEGRAL TYPES limits.h
functions (various limits sizes integral types).
FLOATING-POINT TYPES float.h
functions (various limits sizes floating-point types).
GENERAL LIBRARY DEFINITIONS
ERRORS errno.h
functions (various error return values).
ASSERT assert.h
assert void assert(int expression)
Checks expression.
LIBRARY FUNCTIONS
REFERENCE
This section gives alphabetical list library functions, with full description their operation, options available each one. format each function description follows:
Function name Header filename
atoi
Brief description Declaration Parameters
stdlib.h
Converts ASCII int.
DECLARATION
atoi(const char *nptr)
PARAMETERS
nptr
pointer string containing number ASCII form.
RETURN VALUE
Return value Description
number found string.
DESCRIPTION
Converts ASCII string pointed nptr integer, skipping white space terminating upon reaching unrecognized character.
EXAMPLES
Examples
-3K" gives
gives "149" gives
FUNCTION NAME
name library function.
HEADER FILENAME
function header filename.
BRIEF DESCRIPTION
brief summary function.
abort
DECLARATION
library declaration.
PARAMETERS
Details each parameter declaration.
RETURN VALUE
value, any, returned function.
DESCRIPTION
detailed description covering function's most general use. This includes information about what function useful for, discussion special conditions common pitfalls.
EXAMPLES
more examples illustrating function's use.
abort
stdlib.h
Terminates program abnormally.
DECLARATION
void abort(void)
PARAMETERS
None.
RETURN VALUE
None.
DESCRIPTION
Terminates program abnormally does return caller. This function calls exit function, default entry this resides CSTARTUP.
stdlib.h
Absolute value.
DECLARATION
abs(int
PARAMETERS
value.
RETURN VALUE
having absolute value
DESCRIPTION
Computes absolute value
acos
math.h
cosine.
DECLARATION
double acos(double arg)
PARAMETERS
double range [-1,+1].
RETURN VALUE
double cosine arg, range [0,pi].
DESCRIPTION
Computes principal value radians cosine arg.
asin
asin
math.h
sine.
DECLARATION
double asin(double arg)
PARAMETERS
double range [-1,+1].
RETURN VALUE
double sine arg, range [-pi/2,+pi/2].
DESCRIPTION
Computes principal value radians sine arg.
assert
assert.h
Checks expression.
DECLARATION
void assert (int expression)
PARAMETERS
expression
expression checked.
RETURN VALUE
None.
DESCRIPTION
This macro that checks expression. false prints message stderr calls abort. message following format:
File name; line Assertion failure "expression"
atan
ignore assert calls #define NDEBUG statement before #include <assert.h> statement.
atan
math.h
tangent.
DECLARATION
double atan(double arg)
PARAMETERS
double value.
RETURN VALUE
double tangent arg, range [-pi/2,pi/2].
DESCRIPTION
Computes tangent arg.
atan2
math.h
tangent with quadrant.
DECLARATION
double atan2(double arg1, double arg2)
PARAMETERS
arg1 arg2
double value. double value.
RETURN VALUE
double tangent arg1/arg2, range [-pi,pi].
atof
DESCRIPTION
Computes tangent arg1/arg2, using signs both arguments determine quadrant return value.
atof
stdlib.h
Converts ASCII double.
DECLARATION
double atof(const char *nptr)
PARAMETERS
nptr
pointer string containing number ASCII form.
RETURN VALUE
double number found string.
DESCRIPTION
Converts string pointed nptr double-precision floatingpoint number, skipping white space terminating upon reaching unrecognized character.
EXAMPLES
-3K" gives -3.00 ".0006" gives 0.0006 "1e-4" gives 0.0001
atoi
stdlib.h
Converts ASCII int.
DECLARATION
atoi(const char *nptr)
atol
PARAMETERS
nptr
pointer string containing number ASCII form.
RETURN VALUE
number found string.
DESCRIPTION
Converts ASCII string pointed nptr integer, skipping white space terminating upon reaching unrecognized character.
EXAMPLES
-3K" gives gives "149" gives
atol
stdlib.h
Converts ASCII long int.
DECLARATION
long atol(const char *nptr)
PARAMETERS
nptr
pointer string containing number ASCII form.
RETURN VALUE
long number found string.
DESCRIPTION
Converts number found ASCII string pointed nptr long integer value, skipping white space terminating upon reaching unrecognized character.
bsearch
EXAMPLES
-3K" gives gives "149" gives
bsearch
stdlib.h
Makes generic search array.
DECLARATION
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, (*compare) (const void *_key, const void *_base));
PARAMETERS
base nmemb size compare
Pointer searched object. Pointer array search. Dimension array pointed base. Size array elements. comparison function which takes arguments returns: (negative value) _key less than _base. _key equals _base. (positive value) _key greater than _base.
RETURN VALUE
Result Successful Value pointer element array that matches key.
Unsuccessful Null.
DESCRIPTION
Searches array nmemb objects, pointed base, element that matches object pointed key.
calloc
calloc
stdlib.h
Allocates memory array objects.
DECLARATION
void *calloc(size_t nelem, size_t elsize)
PARAMETERS
nelem elsize
number objects. value type size_t specifying size each object.
RETURN VALUE
Result Successful Unsuccessful Value pointer start (lowest address) memory block. Zero there memory block required size greater available.
DESCRIPTION
Allocates memory block array objects given size. ensure portability, size given absolute units memory such bytes, terms size sizes returned sizeof function. availability memory depends default heap size, Heap size, page
ceil
math.h
Smallest integer greater than equal arg.
DECLARATION
double ceil(double arg)
PARAMETERS
double value.
RETURN VALUE
double having smallest integral value greater than equal arg.
DESCRIPTION
Computes smallest integral value greater than equal arg.
math.h
Cosine.
DECLARATION
double cos(double arg)
PARAMETERS
double value radians.
RETURN VALUE
double cosine arg.
DESCRIPTION
Computes cosine radians.
cosh
math.h
Hyperbolic cosine.
DECLARATION
double cosh(double arg)
PARAMETERS
double value radians.
RETURN VALUE
double hyperbolic cosine arg.
DESCRIPTION
Computes hyperbolic cosine radians.
stdlib.h
Divide.
DECLARATION
div_t div(int numer, denom)
PARAMETERS
numer demon
numerator. denominator.
RETURN VALUE
structure type div_t holding quotient remainder results division.
DESCRIPTION
Divides numerator numer denominator denom. type div_t defined stdlib.h. division inexact, quotient integer lesser magnitude that nearest algebraic quotient. results defined such that:
quot denom numer
exit
exit
stdlib.h
Terminates program.
DECLARATION
void exit(int status)
PARAMETERS
status
status value.
RETURN VALUE
None.
DESCRIPTION
Terminates program normally. This function does return caller. This function entry resides default CSTARTUP.
math.h
Exponential.
DECLARATION
double exp(double arg)
PARAMETERS
double value.
RETURN VALUE
double with value exponential function arg.
DESCRIPTION
Computes exponential function arg.
fabs
fabs
math.h
Double-precision floating-point absolute.
DECLARATION
double fabs(double arg)
PARAMETERS
double value.
RETURN VALUE
double absolute value arg.
DESCRIPTION
Computes absolute value floating-point number arg.
floor
math.h
Largest integer less than equal.
DECLARATION
double floor(double arg)
PARAMETERS
double value.
RETURN VALUE
double with value largest integer less than equal arg.
DESCRIPTION
Computes largest integral value less than equal arg.
fmod
fmod
math.h
Floating-point remainder.
DECLARATION
double fmod(double arg1, double arg2)
PARAMETERS
arg1 arg2
double numerator. double denominator.
RETURN VALUE
double remainder division arg1/arg2.
DESCRIPTION
Computes remainder arg1/arg2, value arg1-i*arg2, some integer such that, arg2 non-zero, result same sign arg1 magnitude less than magnitude arg2.
free
stdlib.h
Frees memory.
DECLARATION
void free(void *ptr)
PARAMETERS
pointer memory block previously allocated malloc, calloc, realloc.
RETURN VALUE
None.
DESCRIPTION
Frees memory used object pointed ptr. must earlier have been assigned value from malloc, calloc, realloc.
frexp
frexp
math.h
Splits floating-point number into parts.
DECLARATION
double frexp(double arg1, *arg2)
PARAMETERS
arg1 arg2
Floating-point number split. Pointer integer contain exponent arg1.
RETURN VALUE
double mantissa arg1, range 1.0.
DESCRIPTION
Splits floating-point number arg1 into exponent stored *arg2, mantissa which returned value function. values follows: mantissa 2exponent value
getchar
stdio.h
Gets character.
DECLARATION
getchar(void)
PARAMETERS
None.
RETURN VALUE
with ASCII value next character from standard input stream.
gets
DESCRIPTION
Gets next character from standard input stream. should customize this function particular target hardware configuration. function supplied source format file getchar.c.
gets
stdio.h
Gets string.
DECLARATION
char *gets(char
PARAMETERS
pointer string that receive input.
RETURN VALUE
Result Successful Unsuccessful Value pointer equal Null.
DESCRIPTION
Gets next string from standard input places string pointed string terminated line file. end-of-line character replaced zero. This function calls getchar, which must adapted particular target hardware configuration.
isalnum
isalnum
ctype.h
Letter digit equality.
DECLARATION
isalnum(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero letter digit, else zero.
DESCRIPTION
Tests whether character letter digit.
isalpha
ctype.h
Letter equality.
DECLARATION
isalpha(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero letter, else zero.
DESCRIPTION
Tests whether character letter.
iscntrl
iscntrl
ctype.h
Control code equality.
DECLARATION
iscntrl(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero control code, else zero.
DESCRIPTION
Tests whether character control character.
isdigit
ctype.h
Digit equality.
DECLARATION
isdigit(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero digit, else zero.
DESCRIPTION
Tests whether character decimal digit.
isgraph
isgraph
ctype.h
Printable non-space character equality.
DECLARATION
isgraph(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero printable character other than space, else zero.
DESCRIPTION
Tests whether character printable character other than space.
islower
ctype.h
Lower case equality.
DECLARATION
islower(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero lower case, else zero.
DESCRIPTION
Tests whether character lower case letter.
isprint
isprint
ctype.h
Printable character equality.
DECLARATION
isprint(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero printable character, including space, else zero.
DESCRIPTION
Tests whether character printable character, including space.
ispunct
ctype.h
Punctuation character equality.
DECLARATION
ispunct(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero printable character other than space, digit, letter, else zero.
DESCRIPTION
Tests whether character printable character other than space, digit, letter.
isspace
isspace
ctype.h
White-space character equality.
DECLARATION
isspace (int
PARAMETERS
representing character.
RETURN VALUE
which non-zero white-space character, else zero.
DESCRIPTION
Tests whether character white-space character, that following: Character Space Formfeed Newline Carriage return Horizontal Vertical Symbol
isupper
ctype.h
Upper case equality.
DECLARATION
isupper(int
PARAMETERS
representing character.
isxdigit
RETURN VALUE
which non-zero upper case, else zero.
DESCRIPTION
Tests whether character upper case letter.
isxdigit
ctype.h
digit equality.
DECLARATION
isxdigit(int
PARAMETERS
representing character.
RETURN VALUE
which non-zero digit upper lower case, else zero.
DESCRIPTION
Tests whether character hexadecimal digit upper lower case, that 0-9, a-f, A-F.
labs
stdlib.h
Long absolute.
DECLARATION
long labs(long
PARAMETERS
long value.
ldexp
RETURN VALUE
long absolute value
DESCRIPTION
Computes absolute value long integer
ldexp
math.h
Multiply power two.
DECLARATION
double ldexp(double arg1,int arg2)
PARAMETERS
arg1 arg2
double multiplier value. power value.
RETURN VALUE
double value arg1 multiplied raised power
arg2.
DESCRIPTION
Computes value floating-point number multiplied raised power.
ldiv
stdlib.h
Long division
DECLARATION
ldiv_t ldiv(long numer, long denom)
PARAMETERS
numer denom
long numerator. long denominator.
RETURN VALUE
struct type ldiv_t holding quotient remainder division.
DESCRIPTION
Divides numerator numer denominator denom. type ldiv_t defined stdlib.h. division inexact, quotient integer lesser magnitude that nearest algebraic quotient. results defined such that:
quot denom numer
math.h
Natural logarithm.
DECLARATION
double log(double arg)
PARAMETERS
double value.
RETURN VALUE
double natural logarithm arg.
DESCRIPTION
Computes natural logarithm number.
log10
log10
math.h
Base-10 logarithm.
DECLARATION
double log10(double arg)
PARAMETERS
double number.
RETURN VALUE
double base-10 logarithm arg.
DESCRIPTION
Computes base-10 logarithm number.
longjmp
setjmp.h
Long jump.
DECLARATION
void longjmp(jmp_buf env, val)
PARAMETERS
struct type jmp_buf holding environment, setjmp. value returned corresponding setjmp.
RETURN VALUE
None.
DESCRIPTION
Restores environment previously saved setjmp. This causes program execution continue return from corresponding setjmp, returning value val.
malloc
malloc
stdlib.h
Allocates memory.
DECLARATION
void *malloc(size_t size)
PARAMETERS
size
size_t object specifying size object.
RETURN VALUE
Result Successful Unsuccessful Value pointer start (lowest byte address) memory block. Zero, there memory block required size greater available.
DESCRIPTION
Allocates memory block object specified size, Heap size, page
memchr
string.h
Searches character memory.
DECLARATION
void *memchr(const void size_t
PARAMETERS
pointer object. representing character. value type size_t specifying size each object.
memcmp
RETURN VALUE
Result Successful Unsuccessful Value pointer first occurrence characters pointed Null.
DESCRIPTION
Searches first occurrence character pointed-to region memory given size. Both single character characters object treated unsigned.
memcmp
string.h
Compares memory.
DECLARATION
memcmp(const void *s1, const void *s2, size_t
PARAMETERS
pointer first object. pointer second object. value type size_t specifying size each object.
RETURN VALUE
integer indicating result comparison first characters object pointed with first characters object pointed Return value
Meaning
memcpy
DESCRIPTION
Compares first characters objects.
memcpy
string.h
Copies memory.
DECLARATION
void *memcpy(void *s1, const void *s2, size_t
PARAMETERS
pointer destination object. pointer source object. number characters copied.
RETURN VALUE
DESCRIPTION
Copies specified number characters from source object destination object. objects overlap, result undefined, memmove should used instead.
memmove
string.h
Moves memory.
DECLARATION
void *memmove(void *s1, const void *s2, size_t
memset
PARAMETERS
pointer destination object. pointer source object. number characters copied.
RETURN VALUE
DESCRIPTION
Copies specified number characters from source object destination object. Copying takes place source characters first copied into temporary array that does overlap either object, then characters from temporary array copied into destination object.
memset
string.h
Sets memory.
DECLARATION
void *memset(void size_t
PARAMETERS
pointer destination object. representing character. size object.
RETURN VALUE
DESCRIPTION
Copies character (converted unsigned char) into each first specified number characters destination object.
modf
modf
math.h
Fractional integer parts.
DECLARATION
double modf(double value, double *iptr)
PARAMETERS
value iptr
double value. pointer double that receive integral part value.
RETURN VALUE
fractional part value.
DESCRIPTION
Computes fractional integer parts value. sign both parts same sign value.
math.h
Raises power.
DECLARATION
double pow(double arg1, double arg2)
PARAMETERS
arg1 arg2
double number. double power.
RETURN VALUE
arg1 raised power arg2.
DESCRIPTION
Computes number raised power.
printf
printf
stdio.h
Writes formatted data.
DECLARATION
printf(const char *format,
PARAMETERS
format
pointer format string. optional values that printed under control format.
RETURN VALUE
Result Successful Unsuccessful Value number characters written. negative value, error occurred.
DESCRIPTION
Writes formatted data standard output stream, returning number characters written negative value error occurred. Since complete formatter demands space there several different formatters choose. more information chapter Configuration.
format string consisting sequence characters printed conversion specifications. Each conversion specification causes next successive argument following format string evaluated, converted, written.
form conversion specification follows:
[flags] [field_width] [.precision] [length_modifier] conversion
Items inside optional.
printf
Flags flags follows: Flag
space
Effect Left adjusted field. Signed values will always begin with plus minus sign. Values will always begin with minus space. Alternate form: Specifier Effect
octal
First digit will always zero. Decimal point printed trailing zeros kept. Decimal point printed. Non-zero values prefixed with
Non-zero values prefixed with Zero padding field width (for specifiers).
Field width field_width number characters printed field. field will padded with space needed. negative value indicates left-adjusted field. field width stands value next successive argument, which should integer. Precision precision number digits print integers number decimals printed floating-point values number significant digits conversions. field width stands value next successive argument, which should integer.
printf
Length modifier effect each length_modifier follows: Modifier
Before specifiers denote short unsigned short value. Before specifiers denote long integer unsigned long value. Before specifiers denote long double value.
Conversion result each value conversion follows: Conversion
Result Signed decimal value. Signed decimal value. Unsigned octal value. Unsigned decimal value. Unsigned hexadecimal value, using lower case (0-9, a-f). Unsigned hexadecimal value, using upper case (0-9, A-F). Double value style [-]d.ddde+dd. Double value style [-]d.dddE+dd. Double value style [-]ddd.ddd. Double value style whichever more appropriate. Double value style whichever more appropriate. Single character constant. String constant. Pointer value (address).
printf
Conversion
Result output, store number characters written integer pointed next argument.
character.
Note that promotion rules convert char short arguments while floats converted double.
printf calls library function putchar, which must adapted
target hardware configuration. source printf provided file printf.c. source reduced version that uses less program space stack provided file intwri.c.
EXAMPLES
After following statements:
i=6, j=-6; char "ABC"; long l=100000; float 0.0000001; 750000; double 2.2;
effect different printf function calls shown following table; represents space:
putchar
Statement
printf("%c",p[1]) printf("%d",i) printf("%3d",i) printf("%.3d",i) printf("%-10.3d",i) printf("%10.3d",i) printf("Value=%+3d",i) printf("%10.*d",i,j) printf("String=[%s]",p) printf("Value=%lX",l) printf("%f",f1) printf("%f",f2) printf("%e",f1) printf("%16e",d) printf("%.4e",d) printf("%g",f1) printf("%g",f2) printf("%g",d)
Output
Value=+6 -000006 String=[ABC] Value=186A0 0.000000 750000.000000 1.000000e-07 2.200000e+00 2.2000e+00 1e-07 750000
Characters output
putchar
stdio.h
Puts character.
DECLARATION
putchar(int value)
PARAMETERS
value
representing character put.
puts
RETURN VALUE
Result Successful Unsuccessful Value
value.
macro.
DESCRIPTION
Writes character standard output. should customize this function particular target hardware configuration. function supplied source format file putchar.c. This function called printf.
puts
stdio.h
Puts string.
DECLARATION
puts(const char
PARAMETERS
pointer string put.
RETURN VALUE
Result Successful Unsuccessful Value non-negative value. error occurred.
DESCRIPTION
Writes string followed new-line character standard output stream.
qsort
qsort
stdlib.h
Makes generic sort array.
DECLARATION
void qsort (const void *base, size_t nmemb, size_t size, (*compare) (const void *_key, const void *_base));
PARAMETERS
base nmemb size compare
Pointer array sort. Dimension array pointed base. Size array elements. comparison function, which takes arguments returns: (negative value) _key less than _base. _key equals _base. (positive value) _key greater than _base.
RETURN VALUE
None.
DESCRIPTION
Sorts array nmemb objects pointed base.
rand
stdlib.h
Random number.
DECLARATION
rand(void)
PARAMETERS
None.
realloc
RETURN VALUE
next random number sequence.
DESCRIPTION
Computes next current sequence pseudo-random integers, converted range [0,RAND_MAX]. srand description seed pseudo-random sequence.
realloc
stdlib.h
Reallocates memory.
DECLARATION
void *realloc(void *ptr, size_t size)
PARAMETERS
size
pointer start memory block. value type size_t specifying size object.
RETURN VALUE
Result Successful Unsuccessful Value pointer start (lowest address) memory block. Null, memory block required size greater available.
DESCRIPTION
Changes size memory block (which must allocated malloc, calloc, realloc).
scanf
scanf
stdio.h
Reads formatted data.
DECLARATION
scanf(const char *format,
PARAMETERS
format
pointer format string. Optional pointers variables that receive values.
RETURN VALUE
Result Successful Unsuccessful Value number successful conversions. input exhausted.
DESCRIPTION
Reads formatted data from standard input. Since complete formatter demands space there several different formatters choose. more information Input output, page
format string consisting sequence ordinary characters conversion specifications. Each ordinary character reads matching character from input. Each conversion specification accepts input meeting specification, converts assigns object pointed next successive argument following format.
format string contains white-space characters, input scanned until non-white-space character found. form conversion specification follows:
[assign_suppress] [field_width] [length_modifier] conversion
Items inside optional.
scanf
Assign suppress included this position, field scanned assignment carried out. field_width field_width maximum field scanned. default until match occurs. length_modifier effect each length_modifier follows: Length modifier
Before
Meaning
long opposed int. unsigned long opposed unsigned int. double operand opposed float. short opposed int. unsigned short opposed unsigned int.
long double operand opposed float.
Conversion meaning each conversion follows: Conversion
Meaning Optionally signed decimal integer value. Optionally signed integer value standard notation, that decimal, octal (0n) hexadecimal (0xn, 0Xn). Optionally signed octal integer. Unsigned decimal integer. Optionally signed hexadecimal integer. Optionally signed hexadecimal integer (equivalent Floating-point constant.
scanf
Conversion
Meaning Floating-point constant (equivalent Character string. field_width characters. read, store number characters read integer pointed next argument. Pointer value (address). number characters matching characters before terminating example, [abc] means number characters matching characters before further, terminating example, []abc] means number characters matching characters before terminating example, [^abc] means number characters matching characters before further, terminating example, [^]abc] means
character.
conversions except varieties leading white-space characters skipped.
scanf indirectly calls getchar, which must adapted actual
target hardware configuration.
EXAMPLES
example, after following program:
char name[50]; float scanf("%d%f%s", name)
this input line:
54.32E-1 Hello World
setjmp
will variables follows:
5.432, name="Hello World"
this function:
scanf("%2d%f%*d %[0123456789]", name)
with this input line:
56789 0123 56a72
will variables follows:
789.0, name="56" (0123 unassigned)
setjmp
setjmp.h
Sets jump return point.
DECLARATION
setjmp(jmp_buf env)
PARAMETERS
object type jmp_buf into which setjmp store environment.
RETURN VALUE
Zero. Execution corresponding longjmp causes execution continue return from setjmp, which case value value given longjmp returned.
DESCRIPTION
Saves environment later longjmp. Note that setjmp must always used same function higher nesting level than corresponding call longjmp.
math.h
Sine.
DECLARATION
double sin(double arg)
PARAMETERS
double value radians.
RETURN VALUE
double sine arg.
DESCRIPTION
Computes sine number.
sinh
math.h<b

Other recent searches


TMS320C6000 - TMS320C6000   TMS320C6000 Datasheet
KSN-2554A-119+ - KSN-2554A-119+   KSN-2554A-119+ Datasheet
C9692 - C9692   C9692 Datasheet
C9692-01 - C9692-01   C9692-01 Datasheet
C9692-02 - C9692-02   C9692-02 Datasheet
C9692-03 - C9692-03   C9692-03 Datasheet
ADS62P45 - ADS62P45   ADS62P45 Datasheet
ADS62P44 - ADS62P44   ADS62P44 Datasheet
ADS62P43 - ADS62P43   ADS62P43 Datasheet
ADS62P42 - ADS62P42   ADS62P42 Datasheet
ADC1255X - ADC1255X   ADC1255X Datasheet
A68AKY13X - A68AKY13X   A68AKY13X Datasheet
5KE440CA - 5KE440CA   5KE440CA Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive