Due to a change in COFF file format, MPLAB C18 v3.00 and later will not be compatible with versions of MPLINK prior to v4.00 or versions of the MPLAB IDE prior to v7.21.
MPLAB C18 v3.00 and later will have backward compatibility to earlier versions at the source level only. Any existing object files or libraries compiled with earlier versions of the tools will not link using new versions of the tools. They will need to be recompiled from source.
If the user attempts to use this release with object files or libraries compiled with earlier versions of MPLAB C18, MPLINK, and MPASM, the error message that will be received will be similar to:
Error - Coff file format for 'C:\mcc18\lib/c018i.o' is out of date.
If the user attempts to use an old version of MPLINK to link object files or libraries compiled with this release, the error message that will be received will be similar to:
Error - Coff file format for 'C:\mcc18\lib/c018i.o' does not appear to be a valid COFF file.
SPPCFG SPPCON SPPEPS UCON UADDR UCFG UEP0 UEP1 UEP2 UEP3 UEP4 UEP5 UEP6 UEP7 UEP8 UEP9 UEP10 UEP11 UEP12 UEP13 UEP14 UEP15Support files for the following devices were corrected:
| MM | instead of XM20 | for MCU mode - External bus disabled |
| XM12 | instead of XM16 | for Extended MCU mode, 12-bit Address mode |
| XM16 | instead of XM12 | for Extended MCU mode, 16-bit Address mode |
| XM20 | instead of MM | for Extended MCU mode, 20-bit Address mode |
AEXP BEXP AARGB0 AARGB1 AARGB2 AARGB3 AARGB4 AARGB5 AARGB6 AARGB7 BARGB0 BARGB1 BARGB2 BARGB3 REMB0 REMB1 REMB2 REMB3 TEMP TEMPB0 TEMPB1 TEMPB2 TEMPB3 FPFLAGS FPFLAGSbitsIf you are using any of these names to refer to the math library's variables, these can now be accessed by prefixing the symbol name with two underscores (e.g., __FPFLAGS).
18C442 CONFIG1H, CONFIG4L
18C452 CONFIG1H, CONFIG4L
18C658 CONFIG1H, CONFIG4L
18C858 CONFIG1H, CONFIG4L
18F242 CONFIG5L, CONFIG6L, CONFIG7L
18F442 CONFIG5L, CONFIG6L, CONFIG7L
18F6525 CONFIG3L, CONFIG5L, CONFIG6L, CONFIG7L
18F6621 CONFIG3L
18F8525 CONFIG5L, CONFIG6L, CONFIG7L
18F2220 CONFIG5L, CONFIG6L, CONFIG7L
18F4220 CONFIG5L, CONFIG6L, CONFIG7L
18F2439 CONFIG5L, CONFIG6L, CONFIG7L
18F4439 CONFIG5L, CONFIG6L, CONFIG7L
18F2525 CONFIG5L, CONFIG6L, CONFIG7L
18F4525 CONFIG5L, CONFIG6L, CONFIG7L
18F6520 CONFIG2L, CONFIG2H, CONFIG3L, CONFIG3H, CONFIG5L,
CONFIG6L, CONFIG7L
18F6620 CONFIG3L, CONFIG5L, CONFIG6L, CONFIG7L
18F6720 CONFIG3L
18F8520 CONFIG2L, CONFIG2H, CONFIG3H, CONFIG5L, CONFIG6L,
CONFIG7L
18F8620 CONFIG5L, CONFIG6L, CONFIG7L
18F2331 and 18F2431 had extra settings removed that are
unimplemented on these devices as follows:18C242 18C252 18C442 18C452 18C601 18C658 18C801 18C858 18F1220 18F1230 18F1231 18F1320 18F1330 18F1331 18F2220 18F2221 18F2320 18F2321 18F2331 18F2410 18F242 18F2420 18F2423 18F2431 18F2439 18F2450 18F2455 18F248 18F2480 18F24J10 18F2510 18F2515 18F252 18F2520 18F2523 18F2525 18F2539 18F2550 18F258 18F2580 18F2585 18F25J10 18F25K20 18F2610 18F2620 18F2680 18F2681 18F2682* 18F2685 18F4220 18F4221 18F4320 18F4321 18F4331 18F4410 18F442 18F4420 18F4423 18F4431 18F4439 18F4450 18F4455 18F448 18F4480 18F44J10 18F4510 18F4515 18F452 18F4520 18F4523 18F4525 18F4539 18F4550 18F458 18F4580 18F4585 18F45J10 18F45K20 18F4610 18F4620 18F4680 18F4681 18F4682* 18F4685 18F6310 18F6390 18F63J11* 18F63J90 18F6410 18F6490 18F64J11* 18F64J15 18F64J90 18F6520 18F6525 18F6527 18F6585 18F65J10 18F65J11* 18F65J15 18F65J90 18F6620 18F6621 18F6622 18F6627 18F6680 18F66J10 18F66J15 18F66J60 18F66J65 18F6720 18F6722 18F67J10 18F67J60 18F8310 18F8390 18F83J11* 18F83J90 18F8410 18F8490 18F84J11* 18F84J15 18F84J90 18F8520 18F8525 18F8527 18F8585 18F85J10 18F85J11* 18F85J15 18F85J90 18F8620 18F8621 18F8622 18F8627 18F8680 18F86J10 18F86J15 18F86J60 18F86J65 18F8720 18F8722 18F87J10 18F87J60 18F96J60 18F96J65 18F97J60
* New part support since last release
Note: The devices 18F2423, 18F2523, 18F4423, and 18F4523 were
formerly known as 18LF2423, 18LF2523, 18LF4423, 18LF4523.
18F1230 18F1231 18F1330 18F1331 18F2221 18F2321 18F2410 18F2420 18F2423 18F2450 18F2455 18F2480 18F24J10 18F2510 18F2515 18F2520 18F2523 18F2525 18F2550 18F2580 18F2585 18F25J10 18F25K20 18F2610 18F2620 18F2680 18F2682 18F2685 18F4221 18F4321 18F4410 18F4420 18F4423 18F4450 18F4455 18F4480 18F44J10 18F4510 18F4515 18F4520 18F4523 18F4525 18F4550 18F4580 18F4585 18F45J10 18F45K20 18F4610 18F4620 18F4680 18F4682 18F4685 18F6310 18F6390 18F63J11 18F63J90 18F6410 18F6490 18F64J11 18F64J90 18F6527 18F65J10 18F65J11 18F65J15 18F65J90 18F6622 18F6627 18F66J10 18F66J15 18F66J60 18F66J65 18F6722 18F67J10 18F67J60 18F8310 18F8390 18F83J11 18F83J90 18F8410 18F8490 18F84J11 18F84J90 18F8527 18F85J10 18F85J11 18F85J15 18F85J90 18F8622 18F8627 18F86J10 18F86J15 18F86J60 18F86J65 18F8722 18F87J10 18F87J60 18F96J60 18F96J65 18F97J60
THE PARTS CORRESPONDING TO THESE OPTIONS MAY NOT ALL BE COMMERCIALLY AVAILABLE.
The following document revisions are associated with this release:
The current documentation is available from our web site: http://www.microchip.com/c18
The following Help files are associated with this release:
If the installation includes documentation, the files listed above are placed in the <install_dir>\doc directory.
The information in the COFF File Format Help file (Updated March 31, 2006) supercedes the information
found in Appendix A, COFF File Format, Table A-2 of the document:
MPLAB C18 C Compiler User's Guide (DS51288 revision J)
MPLAB C18 requires the use of MPLINK™, Microchip's object linker; MPLAB C18 v3.00 or later will require MPLINK v4.00 or later. The latest version of MPLINK is included with the installation.
To verify correct installation of MPLAB C18, execute the batch file <install_dir>\example\an696\buildit.bat. If the compiler system has been installed correctly, the file 18motor.out will be created.
When installing MPLAB C18, the setup program offers the user the ability to change several environment settings. The following options are provided:
Environment Variables:
MPLAB IDE Configuration:
The options below only appear if the user has a version of MPLAB IDE installed.
If MPLAB C18 is uninstalled, these changes to the IDE configuration will not be rolled back.
See the document "MPLAB C18 C Compiler Getting Started Guide" for a step-by-step tutorial on using MPLAB C18 with the MPLAB IDE.
The current documentation is available from our web site, http://www.microchip.com/c18
NOTE: MPLAB C18 v3.00 and later will not be compatible with versions of the MPLAB IDE prior to v7.21.
The following are some of the known issues with MPLAB C18 v3.03. The first list presented, SSR SUMMARY, is a brief summary of each SSR, System Service Request, for ease of reference. For more details on an SSR, see that SSR in the list SSR DETAILS which follows.
#include <p18cxxx.h>
typedef struct{
unsigned char Name[130];
unsigned char Length;
}_Image;
_Image EImage;
_Image *pImage = &EImage;
void main(void)
{
unsigned short Len;
EImage.Length = 55;
Len = pImage->Length; // Wrong value of Len
}
The compiler will not use the correct offset to find the Length member of EImage.
typedef struct
{
int b;
} typeB;
const typeB objB;
void fB_type( )
{
objB.b = 1;
}
does not generate an error.#pragma romdata whatever = const rom unsigned char = 0x71; #pragma romdatadoes not generate an error and does not create a section named whatever.
struct A {long a, b;} X;
extern struct A foo (void);
long c;
void main (void)
{
c = foo().b;
}
enum {
R=127, // value = 127
G, // value = -128 *** incorrect ***
B // value = 129
};
Workaround: If an enumeration constant with a value of 128 is required,
it should be explicitly given that value. For example,
enum {
R=127, // value = 127
G=128, // value = 128
B // value = 129
};
volatile unsigned char uc_test; uc_test = 80; uc_test *= 0.7; /* Expected: 56, Actual: 0*/A workaround to this is to write the last statement as:
uc_test = uc_test * 0.7;
typedef unsigned short long foo;
typedef unsigned char foo;
typedef unsigned short foo;
typedef unsigned int foo;
typedef unsigned long foo;
typedef double foo;
typedef long double foo;
typedef struct
{
...
} foo;
typedef union foo
{
...
} foo;
It should cause the compiler to emit errors such as:test.c:3: error: conflicting types for `foo' test.c:2: error: previous declaration of `foo'
#pragma romdata constscn=0x2000 rom const unsigned char var; #pragma romdata rom const unsigned char *varptr = &var + 0x8000;The above code gives the following relocation entries:
Relocation: r_vaddr=0x00000000, r_symndx=2, r_offset=-32768, r_type=4 Relocation: r_vaddr=0x00000001, r_symndx=2, r_offset=-32768, r_type=3 Relocation: r_vaddr=0x00000002, r_symndx=2, r_offset=-32768, r_type=21Note that the r_offset field reflects an offset of -32k instead of +32k.
void foo( void )
{
varptr = &var;
varptr += 0x8000;
}
struct { void (*f) (static int x); } S;
void main (void) { S.f (1); }
signed char x; x = 0x80; x >>= 7; /* 'x' should be -1, but is 1 instead */The integer promotions are not performed on 'x'.
rom short long x;
void main (void)
{
short long y;
x = 1025;
y = x %= 2; /* 'x' correctly receives 1, but 'y' does not */
...
unsigned long x[4];
void main (void) { ((void (*)(void))x)( ); }
struct s { int x; } S;
void main (void)
{
struct s; /* this introduces a new type, hiding the previous */
struct s *Sp = &S; /* this is an incompatible assignment */
Sp->x++; /* invalid access of an incomplete type */
...
The inner declaration of 'struct s' introduces a new (incomplete)
type, which is different than the first 'struct s'. However, the
above program compiles quietly. The structure tag is not redefined.#pragma udata U1 int i; #pragma udata U2 int i;If U1 and U2 are allocated into different banks, references to 'i' may not be banked correctly after optimization. The solution is to use only one declaration of each global name.
typedef int *T; rom T p1; T rom p2;Both 'p1' and 'p2' should have type 'rom pointer to ram int'. Instead, only 'p1' has the correct type. 'p2' is given the type 'ram pointer to rom int'.
char a[5]; extern char a[];The size of 'a' is 1, not 5 as it should be.
const rom char x;
char *p;
void main (void) { p = &x; ... }
A diagnostic should be generated. The effect of referencing through
'p' following the assignment is indeterminate.
struct s
{
unsigned long x;
char y;
} S, T;
void main (void)
{
char b;
unsigned long z;
...
z = (b ? S : T).x;
...
generates such an error. The workaround is to use an 'if' statement
instead of the conditional operator.
extern int x = 5;
void main (void) { x++; }
generates an internal error. The workaround is to remove the 'extern'
storage class specification or remove the initializer.signed char x; unsigned char y; ... x /= y;with:
signed char x; unsigned char y; ... x = x / y;-- The compound assignment remainder operator may return incorrect results when the right operand is greater than 8 bits in size. The workaround is to replace
unsigned char x; unsigned short y; ... x %= y;with:
unsigned char x; unsigned short y; ... x = x % y;
void main (void)
{
typedef int X;
{
struct Y { int X; };
(X)3; /* this should refer to the typedef name,
* not the structure member */
}
}
The textually intervening declaration of 'X' as a structure member
causes the typedef declaration of 'X' to be lost.char *s = "hello world";Any references through 's' will result in indeterminate behavior.
struct foo { int a; };
struct foo { char b; };
struct foo F;
compiles quietly without error. The variable 'F' takes on the type of
the second declaration.
void main (void) { extern rom int x; }
Error: local 'x' in program memory can not be 'auto'
Error - could not find definition of symbol '_foo:101' ...Such would be the error message if the function in question is called 'foo'.
void foo(const rom far char * FullPath, char *Path, char *FileName)
{
char *NameStart;
char *s;
if ((NameStart > FullPath + 1) && (*(Path - 1) == '\\'))
return;
}
results in:Fatal [100] - internal - unable to reduce treeThe problem is caused by comparing the address of a pointer located on the stack (i.e. ram) with one located in rom. This is not a valid comparison and should result in an error.
struct complex new_complex(double r, double i);
void main (void)
{
new_complex(10.55, 12.44);
return;
}
struct
{
unsigned char aaa;
volatile unsigned char bbb;
} flags;
the volatile qualifier on the second member of the struct 'flags'
is ignored.
struct
{
unsigned char aaa;
volatile unsigned char bbb;
} volatile flags;
int add( int a, int b )
{
int c;
c = a + b;
return c;
}
Compiled with:
mcc18 test.c -scoThen placed in an archive containing only this file:
mplib -c test.lib test.oMPLIB is unable to list the files in the archive.
mplib -t test.libGives the error:
Error - Coff file 'test.o' could not read string table. Error - Could not build member 'test.o' in library file 'test.lib'.Trying to use such an archive with MPLINK also gives an error saying it could not read the string table.
void foo(unsigned short addr)
{
_asm
movff ((unsigned char *)&addr)+1,1
_endasm
}
The workaround is to use valid inline assembly syntax:movff addr+1,1
void main (void)
{
static char x;
_asm
movff x, x + (unsigned char)1
_endasm
}
The workaround is to remove the cast.
#include <p18f452.h>
void assignlocals( void )
{
auto char a, b;
_asm
// correctly assigns TMR0L to variable 'a'
movlw a
movff TMR0L, PLUSW2
// DOES NOT correctly assign TMR0L to variable 'b'
movff TMR0L, b
_endasm
}
The compiler should give an error (or at least a warning) on the use
of variable 'b' in a direct mode addressing instruction, but it instead
generates code as if the offset were an absolute address.
#define STR(a) NXSTR(a)
#define NXSTR(a) #a
void
foo (void)
{
// Apply "merging" operator
#define CAT(a, b) NXCAT(a, b)
#define NXCAT(a, b) a ## b
// The two tokens '1.' and 'E9' should be merged into a single token
// before the stringization operator is applied.
STR(CAT (1., E9));
}
Preprocesses to:"CAT (1., E9)" ;but it should produce:
"1.E9" ;
#define FOSC 1800 #error "FOSC is 1800"Preprocessor command line:
cpp18 preproc-1.cPreprocessor output:
#line 1 "preproc-1.c" #line 2 "preproc-1.c" preproc-1.c:2: "1800 is 1800"
... /* no #if here */ #elif defined (_FOO_) #endif
#pragma romdata CONFIG _CONFIG_DECL (_OSCS_OFF_1H & _OSC_HSPLL_1H, // comments _PWRT_ON_2L & _BOR_OFF_2L & _BORV_42_2L, // comments 0, _CCP2MUX_OFF_3H, ...Another example:
#include <p18f8720.h>
#pragma romdata CONFIG
_CONFIG_DECL
(_CONFIG1H_DEFAULT,
_CONFIG2L_DEFAULT,
_CONFIG2H_DEFAULT,
_CONFIG3L_DEFAULT,
_CONFIG3H_DEFAULT,
_CONFIG4L_DEFAULT,
_CONFIG5L_DEFAULT,
_CONFIG5H_DEFAULT,
_CONFIG6L_DEFAULT,
_CONFIG6H_DEFAULT,
_CONFIG7L_DEFAULT,
_CONFIG7H_DEFAULT //12
);
#pragma romdata
The workaround is to not have comments inside a macro call.#if defined(x) int y = x;But this does not:
#define x 2 #if defined(x) int y = x;Both should give syntax errors since the #endif is missing.
#ifdef foo #if 12/foo #endif #endif ...Will generate a divide by zero error from the preprocessor, but should not since the expression shouldn't be evaluated.
#define x (4 + y)
#define y (2 * x)
void main (void) { y; }
causes the preprocessor to run indefinitely.
void main (void)
{
int x;
f (arg1,
arg2,
arg3); // macro call
...
x++; // breakpoint may not function correctly here
...
A breakpoint set on a line following such a macro call may not work
correctly. MPLAB IDE may state that such a breakpoint cannot be set.
void main (void)
{
int x;
f (arg1,\
arg2,\
arg3);
...
x++;
Error [1225] configuration value '0' not recognized for configuration setting 'WDT'
#define OFF 0 #define ON 1 #pragma config WDT = OFF ....
char test[]="\\"; // "string"preprocessed with:
mcc18 preproc.c -eresults in:
#line 1 "preproc.c" char test[]="\\"; // "string"Notice that the preprocessor does not remove the comment.
#define _BAR_
#if defined(_FOO_)
#error "_FOO_ defined"
#elsif defined(_BAR_)
#error "_BAR_ defined"
#else
#error "Neither defined"
#endif
will print "Neither defined" since "#elsif" is not a valid
preprocessor directive. Although it should be "#elif" no error
or warning is given about the typo.
#include "c:\test\c18\include\header.h"
void main (void)
{}
compiled with --c:\test\c18\include>mcc18 includepath.ccauses the following path in the COFF file --
C:\test\c18\include\c:\test\c18\include\header.hThe path appears to be the included file's absolute path appended to the current working directory.
C:\test\c18\include\c:\test\c18\include\header.h:1:Error: syntax error
#define symbol #if symbol /* end of file */causes the preprocessor to crash.
#include <p18cxxx.h>
void main(void)
{
while(1);
}
#undef SOME_LABEL /* end of file */
causes the preprocessor to crash.
void main(void)
{
#define f g
#define g f
f(1);
}
causes the preprocessor to hang for a long time, then give an error similar to:Preprocessor Error : out of dynamic memory in yy_scan_buffer
float a, c;
char b[] = ".15625";
void main ( )
{
a = atof (b);
c = .15625;
}
The representation of 'c' is 0x7c200000 and 'a' is 0x7c1fffff.
enum test_enum {alphavar, betavar, gammavar, deltavar = 5, epsilonvar};
typedef struct {
enum test_enum S_FH_FT : 3;
} _c_LsFH_FT_1_msgType;
Microchip gratefully acknowledges the contributions of the following to the development of MPLAB C18.
Daniel Madill, Quanser Consulting --
December 2000, Optimizations to fixed point divide library routines.