PSoC Designer: C Language Compiler

[Pages:16]PSoCTM Designer: C Language Compiler

User Guide

Revision 1.17 (Cypress Revision *B) Spec.# 38-12001

Last Revised: December 5, 2003 Cypress MicroSystems, Inc.

CYPRESS MICROSYSTEMS

Cypress MicroSystems, Inc. 2700 162nd St. SW, Building D

Lynnwood, WA 98037 Phone: 800.669.0557

Fax: 425.787.4641

support@

Copyright ? 2002-2003 Cypress MicroSystems, Inc. All rights reserved. PSoCTM (Programmable System-on-Chip) is a trademark of Cypress MicroSystems, Inc.

Copyright ? 1999-2000 iMAGEcraft Creations Inc. All rights reserved. All Microsoft products referenced herein are either trademarks or registered trademarks of Microsoft Corp.

All Intel products referenced herein are either trademarks or registered trademarks of Intel Corporation. ? Copyright 1994-2002 Motorola, Inc. All Rights Reserved.

The information contained herein is subject to change without notice.

Table of Contents

Table of Contents

List of Tables ................................................................................................. v

Two-Minute Overview ................................................................................... 1

Documentation Conventions ....................................................................... 2

Section 1. Introduction ................................................................................. 3

1.1 What is the PSoC Designer C Compiler? ...................................................................3 1.2 Section Overview ........................................................................................................ 4 1.3 Product Upgrades ........................................................................................................ 4 1.4 Support ........................................................................................................................ 5

Section 2. Accessing the Compiler ............................................................. 7

2.1 Enabling the Compiler ................................................................................................7 2.2 Accessing the Compiler ............................................................................................... 7 2.3 Menu Options ..............................................................................................................8

Section 3. Compiler Files ........................................................................... 11

3.1 Startup File ................................................................................................................ 11 3.2 Library Descriptions ................................................................................................... 11

Section 4. Compiler Basics ........................................................................ 13

4.1 Types ......................................................................................................................... 13 4.2 Operators ................................................................................................................... 14 4.3 Expressions ...............................................................................................................16 4.4 Statements ................................................................................................................16 4.5 Pointers ..................................................................................................................... 17 4.6 Re-entrancy ...............................................................................................................17 4.7 Processing Directives (#'s) ........................................................................................ 17

4.7.1 Preprocessor Directives ................................................................................... 18 4.7.2 pragma Directives ............................................................................................ 18

Section 5. Functions ................................................................................... 21

5.1 Library Functions ....................................................................................................... 21 5.1.1 String Functions ............................................................................................... 21 5.1.2 Mathematical Functions ................................................................................... 24 5.1.3 API Software Library Functions ....................................................................... 26

5.2 Interfacing C and Assembly ....................................................................................... 26

Section 6. Additional Considerations ....................................................... 29

6.1 Accessing M8C Features .......................................................................................... 29 6.2 Addressing Absolute Memory Locations ................................................................... 29 6.3 Assembly Interface and Calling Conventions ............................................................ 30 6.4 Bit Twiddling .............................................................................................................. 30 6.5 Inline Assembly ......................................................................................................... 31 6.6 Interrupts ................................................................................................................... 31 6.7 IO Registers ............................................................................................................... 32

December 5, 2003

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

i

PSoC Designer: C Language Compiler User Guide

6.8 Long Jump/Call .......................................................................................................... 32 6.9 Memory Areas ...........................................................................................................33

6.9.1 Flash Memory Areas ........................................................................................ 33 6.9.2 Data Memory .................................................................................................... 33 6.10 Program and Data Memory Usage .......................................................................... 33 6.10.1 Program Memory ........................................................................................... 33 6.10.2 Data Memory .................................................................................................. 34 6.11 Program Memory as Related to Constant Data ....................................................... 34 6.12 Stack Architecture and Frame Layout .................................................................... 35 6.13 Strings ..................................................................................................................... 35 6.14 Virtual Registers ...................................................................................................... 36 6.15 Convention for Restoring Internal Registers ............................................................ 36

Section 7. Linker ......................................................................................... 37

7.1 Linker Operations ...................................................................................................... 37 7.1.1 Customized Linker Actions ............................................................................... 38

Section 8. Librarian .................................................................................... 39

8.1 Librarian ..................................................................................................................... 39 8.1.1 Compiling a File into a Library Module ............................................................. 39 8.1.2 Listing the Contents of a Library ...................................................................... 42 8.1.3 Adding or Replacing a Module ......................................................................... 42 8.1.4 Deleting a Module ............................................................................................ 42

Section 9. Command Line Compiler Overview ........................................ 43

9.1 Compilation Process .................................................................................................. 43 9.2 Driver ......................................................................................................................... 43 9.3 Compiler Arguments .................................................................................................. 44

9.3.1 Arguments Affecting the Driver ....................................................................... 45 9.3.2 Preprocessor Arguments ................................................................................ 45 9.3.3 Compiler Arguments ....................................................................................... 45 9.3.4 Linker Arguments ............................................................................................ 45

Section 10. Code Compression ................................................................. 47

10.1 Theory of Operation ................................................................................................. 47 10.2 Code Compressor Process ..................................................................................... 47

10.2.1 `C' and Assembly Code .................................................................................. 47 10.2.2 Where are the "Program Execution" Bytes? .................................................. 48 10.2.3 What Can the PSoC Debugger Expect? ........................................................ 48 10.3 PSoC Designer Integration of the Code Compressor .............................................. 48 10.3.1 boot.asm ........................................................................................................ 48 10.3.2 Text Area Requirement for Code Compressor ............................................... 48 10.4 Code Compressor and the AREA Directive ............................................................. 49 10.5 Build Messages ....................................................................................................... 50 10.6 Up against the Wall? ............................................................................................... 50 10.7 Additional Things to Consider When Using Code Compression ............................. 51

Appendix A. Status Window Messages .................................................... 53

1.1 Preprocessor ............................................................................................................. 53 1.2 Preprocessor Command Line Errors ........................................................................ 55 1.3 C Compiler ................................................................................................................ 55 1.4 Assembler ................................................................................................................. 59 1.5 Assembler Command Line Errors ............................................................................. 61 1.6 Linker ........................................................................................................................ 61

ii

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

December 5, 2003

Table of Contents

Index ............................................................................................................ 63

December 5, 2003

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

iii

PSoC Designer: C Language Compiler User Guide

iv

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

December 5, 2003

List of Tables

List of Tables

Table 1: Documentation Conventions .......................................................................................................... 2 Table 2: Compiler Menu Options.................................................................................................................. 8 Table 3: Supported Data Types.................................................................................................................. 13 Table 4: Supported Operators .................................................................................................................... 15 Table 5: Preprocessor Directives ............................................................................................................... 18 Table 6: pragma Directives......................................................................................................................... 18 Table 7: String Functions............................................................................................................................ 22 Table 8: Mathematical Functions................................................................................................................ 24 Table 9: API Software Library Functions .................................................................................................... 26 Table 10: #pragma Fastcall Conventions for Argument Passing ............................................................... 26 Table 11: #pragma Fastcall Conventions for Return Value........................................................................27 Table 12: Compiler Argument Prefixes....................................................................................................... 44 Table 13: Arguments Affecting the Driver................................................................................................... 45 Table 14: Preprocessor Arguments............................................................................................................ 45 Table 15: Compiler Arguments................................................................................................................... 45 Table 16: Linker Arguments ....................................................................................................................... 45 Table A.1: Preprocessor Errors/Warnings.................................................................................................. 53 Table A.2: Preprocessor Command Line Errors/Warnings ........................................................................ 55 Table A.3: C Compiler Errors/Warnings ..................................................................................................... 55 Table A.4: Assembler Errors/Warnings ...................................................................................................... 59 Table A.5: Assembler Command Line Errors/Warnings............................................................................. 61 Table A.6: Linker Errors/Warnings ............................................................................................................. 61

December 5, 2003

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

v

PSoC Designer: C Language Compiler User Guide

vi

Document #: 38-12001 CY Rev. *B CMS Rev. 1.17

December 5, 2003

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download