ByteCraft

所属分类:单片机开发
开发工具:C/C++
文件大小:628KB
下载次数:52
上传日期:2005-08-01 01:30:38
上 传 者pcoony
说明:  这是MICROCHIP 的PIC 系列单片机常用 的C语言编译器。特别对PIC16F877系列 特别好用。
(It is C compiler for PIC of MICROCHIP,especially for PIC16F877,it is very good!)

文件列表:
mpc131 (0, 2001-12-06)
mpc131\$OPTIONS.IDE (217, 1999-02-26)
mpc131\ADDPATH.EXE (6192, 1999-02-26)
mpc131\BCLEDIT.EXE (61520, 1999-02-26)
mpc131\BCLEDIT.TXT (2957, 1999-02-26)
mpc131\BCLINK.EXE (26960, 1999-02-26)
mpc131\DELPATH.EXE (5984, 1999-02-26)
mpc131\DPMI16BI.OVL (63504, 1999-02-26)
mpc131\DPMIINST.EXE (36724, 1999-02-26)
mpc131\DPMILOAD.EXE (22324, 1999-02-26)
mpc131\Examples (0, 2001-12-06)
mpc131\Examples\14000AD.C (2848, 1996-08-16)
mpc131\Examples\AD74.C (1062, 1996-08-16)
mpc131\Examples\AUTO.C (1084, 1996-08-16)
mpc131\Examples\CALLMAP.C (1324, 1996-08-16)
mpc131\Examples\CONFIG.C (1441, 1996-08-16)
mpc131\Examples\DEFINED.C (1418, 1996-08-16)
mpc131\Examples\DELAY12.C (705, 1996-08-16)
mpc131\Examples\DELAY14.C (930, 1996-08-16)
mpc131\Examples\DELAY16.C (700, 1996-08-16)
mpc131\Examples\EE84.C (1282, 1996-08-16)
mpc131\Examples\EXTERNAL.C (3037, 1996-08-16)
mpc131\Examples\ISR16CXX.C (2289, 1999-02-09)
mpc131\Examples\ISR17CXX.C (2113, 1999-02-09)
mpc131\Examples\KEYPAD.C (3064, 1996-08-16)
mpc131\Examples\LCD4.C (5437, 1997-08-15)
mpc131\Examples\LINK (0, 2001-12-06)
mpc131\Examples\LINK\AD (0, 2001-12-06)
mpc131\Examples\LINK\AD\AD.LNK (281, 1999-02-09)
mpc131\Examples\LINK\AD\AD71.C (1115, 1999-02-09)
mpc131\Examples\LINK\AD\DO-AD.BAT (30, 1999-02-09)
mpc131\Examples\LINK\TEST1 (0, 2001-12-06)
mpc131\Examples\LINK\TEST1\TEST1.BAT (122, 1999-02-09)
mpc131\Examples\LINK\TEST1\TEST1.LNK (237, 1999-02-09)
mpc131\Examples\LINK\TEST1\TEST1A.C (988, 1996-08-16)
mpc131\Examples\LINK\TEST1\TEST1B.C (723, 1999-02-09)
mpc131\Examples\LINK\TIMER (0, 2001-12-06)
mpc131\Examples\LINK\TIMER\GO-TIMER.BAT (33, 1999-02-09)
mpc131\Examples\LINK\TIMER\TIMER.LNK (211, 1999-02-09)
mpc131\Examples\LINK\TIMER\TMR0.C (2025, 1999-02-09)
... ...

MPC Version 1.31 Features and Documentation Byte Craft Limited 421 King St. North Waterloo, Ontario Canada N2J 4E4 Sales Information and Customer Support: Byte Craft Limited 421 King St. North Waterloo, Ontario Canada N2J 4E4 Telephone: (519) 888-6911 FAX: (519) 746-6751 Support: support@bytecraft.com Email: info@bytecraft.com Copyright c 1999 Byte Craft Limited Licensed Material. All rights Reserved. The BCLINK and MPC programs and all documentation of these programs are protected by copyrights. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means including electronic, mechanical, photocopying, recording or otherwise without the prior written permission of Byte Craft Limited. February 1999 Table of Contents 1. FEATURES 1.1 BCLINK LINKER 1.2 NAMED ADDRESS SPACE 1.2.1 VARIABLE DECLARATION RAM ALLOCATION ORDER 1.3 BCDIRECT SUPPORT 1.4 ENVIRONMENT VARIABLE SUPPORT: LIB AND INCLUDE 1.5 _ _FILE_ _ ANSI CHANGE 1.6 WARNINGS AND ERROR MESSAGES 1.7 NEW #PRAGMA DIRECTIVES 1.8 NEW MACRO OPERATOR 1.9 SUPPORT FOR STATIC 1.10 LIBRARY OBJECTS CALLED DIRECTLY FROM MPC 1.11 HEADER FILES 1.11.1 NEW SPACE SAVING CONSTANT: NOLONG 1.11.2 NEW MEMORY SIZE SPECIFICATION: MAXROM 1.12 INTERRUPT SUPPORT MACROS 1.13 LIBRARIES 1.14 32-BIT RESULT IN 16-BY-16 MULTIPLY ROUTINES 1.15 MPC ON HP-UX, SUN SPARC AND NEC-PC 1.16 MPC AND MPLAB 1.17 MPC SUPPORT FOR 8K 14BIT PARTS 2. DOCUMENTATION CHANGES 2.1 LOCATING FUNCTIONS AT FIXED ADDRESSES 2.2 USING THE DEFINED() FUNCTION 2.3 POINTER DECLARATION 2.4 DATA TYPE DECLARATION 3. DEVELOPMENT HINTS 3.1 17CXX CODE AND DATA RESTRICTIONS 3.2 LONG POINTERS 3.3 CONSTANT ROM ARRAYS AND FAR POINTERS 3.4 PREPROCESSOR RESTRICTIONS 3.5 MACRO ASSEMBLER RESTRICTIONS 3.6 STRUCTURE RESTRICTIONS 3.7 MISCELLANEOUS RESTRICTIONS 4. LIBRARIES 4.1 MATH LIBRARY 4.2 PERIPHERAL LIBRARY 4.3 PIC16C5X LIBRARY REFERENCE 4.3.1 DELAY LIBRARY FOR 16C5X 4.4 PIC16CXX LIBRARY REFERENCE 4.4.1 DELAY LIBRARY FOR 16CXX 4.5 ASYNCHRONOUS SERIAL COMMUNICATION FOR PIC16C73/74 4.5.1 MACROS DEFINED IN SER14.H: 4.6 DATA EEPROM LIBRARY FOR PIC16C84 4.7 USING THE 4 CHANNEL A/D 4.8 USING THE 8-CHANNEL A/D 4.9 PIC17CXX LIBRARY REFERENCE 4.9.1 DELAY LIBRARY FOR 17CXX: 4.9.2 17CXX ASYNCHRONOUS SERIAL COMMUNICATIONS 5. BCLINK LINKER 5.1 LINKING MATH ROUTINES 5.1.1 TEMPORARY VARIABLES 5.2 LINKING PROGRAM MODULES 5.2.1 METHOD I: LINKING FILES 5.2.2 METHOD II: CREATING AND LINKING LIBRARIES 5.3 LINKER COMMAND FILES 5.3.1 LINKER COMMAND FILE REQUIREMENTS 5.3.2 LINKER COMMAND FILE OPTIONS 5.4 LINKER COMMANDS 5.5 SAMPLE LINKER COMMAND FILE 5.6 LINKER BATCH FILE 5.7 SAMPLE PROJECT LINK 5.8 MAP FILE FORMAT 5.9 LINKER ERRORS 6. LIMITATIONS 6.1 RAM pointers on 16 bit cores 1. Features ============= The following sections describe new features added to the MPC Code Development System. 1.1 BCLINK Linker BCLINK is a software development tool designed to increase the convenience, flexibility, and efficiency of your Byte Craft Limited MPC Code Development System. BCLINK allows for the linking of object modules compiled with the MPC Code Development System. Use BCLINK to link prepared object modules together and build an executable program. Object files containing functions commonly used in projects can be created and linked into individual projects by using BCLINK. See the section 5. BCLINK Linker for complete documentation. 1.2 Named Address Space Named address space allows developers to group variables within an application. You can specify as many as 15 named address spaces using the #pragma memory RAM directive. An optional address field, addressname, has been added to the #pragma memory directive. Syntax for the directive is now: #pragma memory RAM [size] @ location; The address field is a superset of existing syntax; therefore, previously written application code will compile without any source changes. For example, on the PIC16C57 the locations 0x09 to 0x0F can be defined as an address space of name register. The advantage of using this section of RAM is that it does not require bank switching instruction for access. Variables located in this area are accessible at all times. Therefore, it is a logical location for the user to allocate variables used in timing-critical sections of code to avoid the overhead of bank switching instructions. Variables are declared in this location by declaring them as follows: unsigned int register i, j, k; The compiler allocates these variables in the unbanked section of RAM. If MPC runs out of space in the named space and you try to allocate additional named space variables, it issues a warning message. If unnamed RAM space is full and you declare normal variables, MPC will start using the named space for these variables. Please refer to the example NAMEADDR.C. The header file named 16C57N.H, used in the example NAMEADDR.C, uses named address space on the PIC16C57. Also, in the 17C43.H and 17C44.H and their variants, RAM bank 0 is declared with the name bank0 and bank 1 with the name bank1. This allows you to specify that certain data must go in bank0. Unnamed data will go to bank 0 until it is full, then it will go to bank 1. 1.2.1 Variable Declaration RAM Allocation Order MPC has a specific RAM allocation order for variable declarations: Regular . Search for space in general, unnamed Declarations address space . Search named address space in order of first declaration of each different name Named . Search specified named address space. If Declarations space is not found, generate a warning messages . Search for space in general, unnamed address space . Search remaining named address spaces in order of first declaration of each different name 1.3 BCdirect Support The MPC compiler supports direct communication to debug environments. Embedded BCdirect commands can be used to pre- set breakpoints, pass set up information, and embed print and log statements without impacting generated code. BCdirect information is passed as messages in the .COD file. 1.4 Environment Variable Support: LIB and INCLUDE The environment variables LIB and INCLUDE can be used to specify the paths for the library and include file directories. 1.5 _ _FILE_ _ ANSI Change _ _FILE_ _ returns the currently open file, instead of the main .C source file. 1.6 Warnings and Error Messages 1) When inline assembly code is used, the compiler issues a warning if you try to access a variable in a register bank other than bank 0. A warning is issued if you make a CALL or GOTO to a location in page 1. This serves as a reminder to the users to set the appropriate page or bank bit. To suppress this warning AND the operand with an appropriate mask. For example, to suppress the warning when accessing the TRISB register on 14 bit core PICs use: MOVWF TRISB&0x7F. To suppress the warning when calling a function in page 1 on 14 bit core PICs use: CALL FuncName&0x7FFF. For the 12-bit core PICs use the mask 0x1F for RAM access and 0x1FF for function calls. 2) In the event that you have an opening brace or comment, the compiler gives an error at the end of your source file or the beginning line of the math library. 3) Warning message when space in desired named address space is not available. 4) Error Message for declaration of overlapping named RAM space from different declarations. 5) Error Message when number of different named address spaces exceeds 15 1.7 New #pragma Directives #pragma option BLON Turns on forward bank select optimization. #pragma option BLON is the default setting. If this option is used in source code it should be positioned just prior to the beginning of a function. #pragma option BLOFF Turns off forward bank select optimization. This option should be positioned just prior to the beginning of a function. #pragma _ _CONFIG @ Location = Value Allows the user to set the configuration fuses inside his source program. For example, #pragma _ _CONFIG @ 0x2007 = 0x03F;. Please refer to CONFIG.C on the distribution disk. #pragma option CallMap This option displays a call tree for the functions in your program. It can be used to detect mutually exclusive functions so that local variables can be reused. Please refer to the example CALLMAP.C on the distribution disk. #pragma option RAMMAP; This option is now on by default. It graphically displays RAM usage at the end of the listing file. 1.8 New Macro Operator MPC now supports the ## operator for macro concatenation. For example: #define DataDir(port) TRIS##port When DataDir(B) is called it expands to TRISB. See DEFINED.C for an example on using macro concatenation. 1.9 Support for static MPC supports the ANSI standard uses for the static storage class modifier: 1) When variables are declared and initialized at the same time, the compiler generates code to load the variables with the values. For static local variables, this is only done once at the beginning of the program. Further calls to the function do not reinitialise the variables, thus preserving their values. Please refer to the example STATIC.C. 2) When used with the linker, it limits the scope of global variables to the module in which it is declared. For more information, please refer to section 5. BCLINK Linker. 1.10 Library Objects Called Directly from MPC The MPC compiler can recognise object files and objects can be included by the MPC compiler even in absolute code generation mode. This is very useful when generating standard project libraries. This can be done as follows: 1) Compile the library to object. For example, to compile the math library for the 14-bit core you would use the command: MPC MPC14.LIB +o 2) Move the MPC14.LIB in C source code to a safe place. 3) Rename MPC14.OBJ to MPC14.LIB. 4) The compiler can now use the pre-compiled library instead of the C source code library. 5) The same procedure works for user libraries that are included at the end of the user program. Note: All #include directives which include a library in object form must be the final lines in your source code program. This is necessary in order to ensure that only the functions actually called in your source program are included from the library. The library must also be compiled with the same version of MPC that is used to compile the user program. Otherwise you will get an error message from MPC. 1.11 Header Files As new devices are introduced by Microchip, header files for these new devices are available from Byte Craft's support and shipped with new updates to registered customers. The header files for the 16C6x/7x/8x and 17Cxx have been updated to include macros for context saving and restoring. These macros are SaveContext and RestoreContext and they are to be called at the start and end of interrupt service routines _ _INT(). Please refer to the examples ISR*.C on the distribution disk. 1.11.1 New Space Saving Constant: NOLONG The 16/C6x/7x/8x and 17Cxx header files now recognize a new #define constant NOLONG. If there are no long variables in your program use the directive #define NOLONG before including the processor header file. This will prevent the compiler from allocating space for _ _longAC, _ _longIX, temp_longAC and temp_longIX which will save 8 bytes of RAM. It will also reduce the size of the SaveContext and RestoreContext macros mentioned above. 1.11.2 New Memory Size Specification: MAXROM The #define MAXROM specifies the program memory size. It can be used when a portion of program code is allocated at a specific memory location using the #pragma memory ROM directive. The example below locates func1() at address 0x20 and also ensures that the program does not go beyond the memory limit. #pragma memory ROM[MAXROM - 0x20] @ 0x20; void func1(int i) { } 1.12 Interrupt support macros All header files now contain two macros: SaveContext and RestoreContext. Use these macros as shown in the examples ISR16Cxx.C, and ISR17Cxx.C on the distribution disk. Note: If you have code written for a PIC with 4K of program memory and are using the new header files provided with this release, you must add the SaveContext macro at the beginning of your _ _INT(). 1.13 Libraries Library functions have been added to support delays for 16C5x, delays for 16Cxx, asynchronous serial communication for PIC16C73/74, data EEPROM for PIC16C84, the 4 Channel A/D, the 8-channel A/D, delays for 17Cxx, and asynchronous serial communications for 17Cxx. 1.14 32-bit Result in 16-by-16 Multiply Routines The user can now optionally decide if the math library should calculate the high word of a 16-by-16 multiply result. This can be done by declaring the unsigned long variable _ _HiWord. After the multiply operation, this variable will contain the high word of the result. Please refer to the example MUL32.C on the distribution disk. 1.15 MPC on HP-UX, SUN SPARC and NEC-PC The MPC compiler is now available for the HP 700 series under HP- UX and for the SUN SPARC under either Solaris or SUN-OS. There is also a version of the MPC compiler available to run on the NEC-PC development platform. 1.16 MPC and MPLAB MPC is compatible with Microchip's MPLAB development environment. It works with the MPLAB-SIM simulator and the PICMASTER emulator system. To configure MPLAB to work with MPC: 1) Make sure MPC.EXE is in your DOS PATH or in the same directory as MPLAB 2) Start MPLAB and open the Project menu 3) Select the item Add/Modify Compiler 4) In the dialog box that appears click the Compilers radio button 5) Under the Command Line click the down arrow and select MPC 6) The Compiler Name field should now read Byte Craft MPC 7) You can now edit, recompile, and simulate your MPC programs from within MPLAB 8) To enable C source-level debugging with MPC, the first line of your program must be: #pragma option v; 1.17 MPC SUPPORT FOR 8K 14BIT PARTS MPC V1.31 supports all of the new Microchip PIC parts. The biggest change has been the added support for the 14 Bit parts which can now access 8K instructions in ROM. Compiler support for these parts is automatic when using these parts. (16C66,16C67, 16C76,16C77) 2. Documentation Changes ========================== These changes apply to the MPC User Manual v1.2. 2.1 Locating Functions at Fixed Addresses Page 43 in the manual shows an incorrect method for locating functions at a fixed address using the @ operator. The @ operator is used to fix variables in memory and to define the address of functions fixed in external ROM. Please use the #pragma memory method described in section 1.11.2 New Memory Size Specification: MAXROM to fix a function in program memory. 2.2 Using the defined() function Page 45 mentions that parenthesis are not needed with the defined() function. This is not true. 2.3 Pointer declaration Page 82 states that _near and _far can be used to declare a pointer. The compiler does not recognize the types _near and _far, only near and far. 2.4 Data Type Declaration On page 88 the comment next to the declaration long b in the example should read /* 16-bit word, LOW byte first */ 3. Development Hints ====================== The following sections cover development hints and compiler restrictions. 3.1 17Cxx Code and Data Restrictions 1) The maximum program size supported by MPC is 32K. This includes code and data stored in program memory. 2) If ROM arrays are accessed with pointers, the address of the array must be masked with 0x7FFF. For example: const char Str[] = "Hello"; char near *p; p = Str & 0x7FFF; 3) You can use bank 1 to store variables. However, pointers can only point to objects in bank 0. Declare variables in bank 0 by using: int bank0 var_name; /* force variable in bank 0 */ int *ptr; /* pointer can be anywhere */ ptr = &var_name; /* works without problems */ For more information, please refer to section 1.6 Named Address Space. 4) If code size is greater than 8K, variables should not be initialized in their declaration. Instead of the statement int x=0x12;, use the declaration statement int x; followed by the initialization statement x=0x12;. 3.2 Long Pointers The following are not supported with long pointers: 1) Array-style access syntax, such as l = p[i]; (assuming the declaration long *p;) 2) Pointer dereference with an offset, such as l = *(p+1); 3) Comparing data dereferenced by pointers to other data, such as if (l > *p) {} 3.3 Constant ROM Arrays and Far Pointers 1) In general, due to the fact that data stored in program memory is accessed as code, you should try to use simple expressions to read data. This ensures correct and optimal code generation. It is best to read data from ROM into a temporary variable before performing an operation on the data. 2) Constant strings should be declared as arrays not pointers. Use: const char Msg[]="Hello World \r\n"; instead of: const char *Msg="Hello World \r\n"; 3) On 12-bit core PICs such as the 16C5x and 12Cxx families, only integer and character ROM arrays are supported. Long ROM arrays are not supported. 4) On 16-bit core PICs such as the 17Cxx, reading ROM arrays must be done using simple expressions such as: y = x[i]; instead of the unsupported y = x[i+1];. 5) Passing a ROM array to a function, such as passing a ROM string to puts(), can be done by declaring the argument to the function as a far pointer. If you are passing a RAM array, use a near pointer. The compiler assumes that pointers are far by default when they appear in function arguments. This is not supported on 12-bit core PIC devices. 6) When reading contents referenced by a far ... ...

近期下载者

相关文件


收藏者