Release Notes for MPLAB® C Compiler for PIC18 MCUs v3.41
13 January 2012

Table of Contents
  1. How the Standard Evaluation Edition Differs from the Full Version
  2. Important Backward Compatibility Notes
  3. What's New in This Release
  4. What's Been Fixed Since v3.30
  5. Devices Supported
  6. MPLAB C Compiler for PIC18 MCUs Documentation
  7. Installation and Upgrades
  8. Using MPLAB C Compiler for PIC18 MCUs with the MPLAB IDE
  9. Known Problems
  10. Contributors
  11. Customer Support
  1. How the Standard Evaluation Edition Differs from the Full Version

    MPLAB C Compiler for PIC18 MCUs is available as either a Standard Evaluation Edition or a full version. This Read Me file is the same in both.

    For 60 days, the Standard Evaluation Edition of MPLAB C Compiler for PIC18 MCUs will function as the full version. After 60 days, the MPLAB C Compiler for PIC18 MCUs Standard Evaluation Edition differs from the full version in the following ways:

    • Not all optimizations will be supported. Namely, procedural abstraction will not be supported.
    • The PIC18 Extended mode (extended instruction set and indexed with literal offset addressing) will not be supported.

    To purchase a full version of the MPLAB C Compiler for PIC18 MCUs, please contact your local distributor or visit http://www.microchip.com/c18.

  2. Important Backward Compatibility Notes

  3. COFF File Format Replaces COD File Format

    Due to the elimination of the COD Format from MPASM ouput, and the use of COFF format instead, new flags have been added to COFF files that are generated by C18 v3.30 and MPASM v5.30. These flags are only recognized by MPLINK v4.30 and above. MPLINK v4.30 and above continue to recognized the old COFF files, however, earlier version of MPLINK may not recognized new COFF files.

    Corrected behavior for programs with no high priority Interrupt Service Routine (ISR) due to removal of the vectors region from linker scripts

    This note is only applicable to programs with the following characteristics:

    1. Explicitly defined low priority ISR and
    2. No defined high priority ISR and
    3. Has the High priority interrupt enabled (either explicity or by not disabling the default)

    In the previous versions of the linker scripts (with the vectors region), no code or data was being placed between the High/Low-priority interrupt vectors. Consequently, with the arrival of a High-priority interrupt, the execution of the program would (erroneously) fall into the low-priority ISR. With the removal of the vectors region from the linker scripts, other data or code may be placed at the addresses between the High and Low priority interrupt vectors. This results in a non-deterministic behavior, upon the arrival of a high priority interrupt for these programs.

    MPLAB C Compiler for PIC18 MCUs Storage Qualifier Handling

    The changes to fix SSR 22612 in MPLAB C18 v3.06 affect programs written without consideration of C language specifications regarding the syntactic use of const, volatile, rom, ram, near, and far qualifiers for user defined types using typedef. An error or a warning will be generated if the compiler detects such problems in code.

    For example in the following code:

    typedef char * cPtr_t;
    cPtr_t rom rompc;
    rom char romc;
    void f(void)
    {
      rompc = &romc;
    }
    

    rompc should be [rom pointer to ram char] so MPLAB C18 v3.06 and later produce a warning indicating there is a qualifier mismatch in assignment. Please note that this program compiles with no warning in MPLAB C Compiler for PIC18 MCUs prior to this fix because in those versions, rompc was incorrectly qualified as [ram pointer to rom char]. Since romc was in rom there was no mismatch in type and qualification for this assignment in earlier versions of MPLAB C Compiler for PIC18 MCUs.

    The qualifiers rom, ram, near, and far are specific to MPLAB C Compiler for PIC18 MCUs. While different from const and volatile from a semantic point of view, they are parsed in the same syntactic context, hence the above example is applicable to all qualifiers. (For more information on the syntax of using qualifiers please refer to your C programming language reference manual. For a description of rom, ram, near, and far qualifiers please refer to the "Storage Qualifiers" section of the MPLAB C18 C Compiler User's Guide.)

    MPLINK™ Linker and MPLAB IDE COFF File Format

    Due to a change in COFF file format, MPLAB C18 v3.00 and later will not be compatible with versions of MPLINK Linker 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 Linker, and MPASM Assembler, 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 Linker 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.
  4. What's New in This Release

  5. What's Been Fixed Since v3.30:


    1. Fixed between v3.40 and v3.41:

      ( C18-585)
      Flash library will not build for devices that don't have EEPGD bit in EECON1.
    2. Fixed between v3.39 and v3.40:

      ( C18-580)
      Incorrect SFR definitions in 14 Header Files (16-bit SFRs) Caused Compiler to treat it as an 8-bit SFRs.
    3. Fixed between v3.38 and 3.39:

      ( C18-574)
      ccp and src folders have restricted access.
      ( C18-575)
      MCC_INCLUDE and PATH for user environment varible not being updated properly.
      ( C18-576)
      C18 pconfig.h missing ECC definition for PIC18F45K20 family.
    4. Fixed between v3.37 and 3.38:

      ( C18-489)
      Handling of enumerated type is incorrect.
      ( C18-525)
      Several bit field definitions in the header file do not match datasheet for 18F47J53 family.
      Remove: ODCON3 bit CTMUDS; ANCON1 bit VBG2EN; LATC bit LATC4; LATC bit LATC5; LATA bit LATA4; TRISC bit TRISC4; TRISC bit TRISC5.
      Correct names: CMSTAT bit C3OUT should be bit COUT3; PORTB bit CTEDG1 should be bit CTED1; PORTB bit CTEDG2 should be bit CTED2.
      ( C18-566)
      Make C18 display resource file version number in its version banner
      ( C18-570)
      In the header file for PIC18FJ devices, 16-bit combined SFR's have been defined as a 'char' which makes the compiler treat it like a 8-bit SFR
      ( UDBC-204)
      CONFIG1H (bit 5) should be unimplemented for 18F87K22 and 18F87K90 family
    5. Fixed between v3.36 and 3.37:

      ( C18-495)
      Implementaion Issues for 18F8720 Family.
      18F6520/8520 only: T1OSCMX bit was added for CONGFIG3H.
      18F6620/6720 only: AD15:AD00 removed from PORTD and PORTE (64-pin devices do not support external memory).
      18F6620/6720/8620/8720 only: PORTB bit CCP2 now called out as CCP2_PORTB. PORTF bits C1OUT and C2OUT now called out as C1OUT_PORTF and C2OUT_PORTF.
      18F8620/8720: PORTH bits AD19:AD16 renamed to A19:A16 (address only not address/data). PORTH bits AD15:AD12 renamed to AN15:AN12 (analog not address/data).
      ( C18-496)
      Bits have been removed from 18F1320/1220 Family.
      LATA.LATA5 (RA5 is an input only)
      DDRA.RA5 (RA5 is an input only)
      PIE2.EDDIE, PIR2.EDDIF, and IPR2.EDDIP (not implemented on these devices)
      ( C18-497)
      Bits have been removed from 18F452 Family.
      18F252 and 18F242 only:
      PIE1.PSPIE, PIR1.PSPIF, and IPR1.PSPIP have been removed (no Parallel Slave Port on 28-pin devices).
      18F452, 18F442, 18F252 and 18F242:
      RCON.nLWRT and RCON.LWRT have been removed (bits for 18Cxxx devices not 18Fxxx devices).
      INTCON2.INT3P and INTCON2.INTEDG3 have been removed (no INT3).
      ( C18-499)
      Bits have been removed from 18C452 Family.
      18C452, 18C442, 18C252, 18C242:
      Removed ADCON1.VCFG0 and ADCON1.VCFG1
      18C252, 18C242 Only:
      PIE1.PSPIE, PIR1.PSPIF, and IPR1.PSPIP have been removed (no Parallel Slave Port on 28-pin devices).
      ( C18-500)
      Bits have been removed from 18F4539 Family.
      18F4539, 18F4439, 18F2539, 18F2439:
      RCON.nLWRT and RCON.LWRT have been removed (bits for 18Cxxx devices not 18Fxxx devices).
      ( C18-501)
      Bits have been removed from 18F458 Family.
      18F458, 18F448, 18F258, 18F248:
      DDRA.RA7 has been removed (no RA7 on these devices).
      INTCON2.INTEDG2 has been removed.
      18F258, 18F248 only:
      PIE1.PSPIE, PIR1.PSPIF, and IPR1.PSPIP were removed (no Parallel Slave Port on 28-pin devices).
      ( C18-502)
      Bits have been removed from 18C858 Family.
      18F858, 18F658:
      Removed TXB2SIDL.SRR, TXB1SIDL.SRR, and TXB0SIDL.SRR
      PORTE bits (ALE, OE, WRL, and WRH) were removed - family does not support external memory.
      PORTD bits (AD<7:0) were removed - family does not support external memory.
      18F858 Only:
      PORTH bits (A<19:16> were removed - family does not support external memory.
      PORTJ bits (AD<15:8> were removed - family does not support external memory.
      ( C18-503)
      Bits have been removed from 18C801 Family.
      18C801, 18C601:
      INTCON2.INTEDG3 has been removed (no INT3).
      PORTB.INT3 has been removed (no INT3).
      18C801 only:
      PORTH have been removed (only has 12 analog channels AN<11:0>).
      ( C18-504)
      Bits have been removed from 18F4320 Family.
      18F2320 and 18F2220 only:
      PORTE has been removed (no PORTE on 28-pin devices, 28-pin devices have no RE3 on the MCLR pin).
      Removed CCP1CON.P1M0, and CCP1CON.P1M1 - unimplimented on 28-pin devices).
      18F4320, 18F4220, 18F2320, 18F2220:
      OSCTUNE2 (Register added on rev C0 devices) This removes the BADRAM location F9A from the old include files.
      ( C18-505)
      Bits have been changed in 18F4431 Family.
      18F4431, 18F4331, 18F2431, 18F2331 :
      AN4 was in bit postion 5 (RA5), now in bit position 4 (RA4).
      WDTCON<6:0> have been removed.
      18F4431, 18F4331 only:
      RE<7:4> have been removed (family only has RE<3:0>).
      LATE<7:3> have been removed (family only has RE<3:0>, RE3 is input only).
      DDRE.RE<7:3> have been removed (family only has RE<3:0>, RE3 is input only).
      18F2431 only:
      Added CONFIG6L.WRT3 and CONFIG6L.WRT2 (data sheet is in error it is the 2431/4431 that should have them (16kB devices))
      Added CONFIG6L.EBTR3 and CONFIG6L.EBTR2 (data sheet is in error it is the 2431/4431 that should have them (16kB devices))
      18F4331 only:
      Removed CONFIG6L.WRT3 and CONFIG6L.WRT2 (data sheet is in error it is the 2331/4331 that should not have them (8kB devices))
      Removed CONFIG6L.EBTR3 and CONFIG6L.EBTR2 (data sheet is in error it is the 2331/4331 that should not have them (8kB devices))
      ( C18-506)
      Bits have been removed from 18F8621 Family.
      18F8621, 18F8525, 18F6621, 18F6525:
      LATG.LATG5 has been removed (RG5 is input only).
      DDRG.RG5 has been removed (RG5 is input only).
      RCON.nLWRT and RCON.LWRT have been removed (18Cxxx parts only).
      18F6621, 18F6525 only:
      PORTD.AD<7:0> have been removed (64-pin devices do not support external memory).
      ( C18-507)
      Bits have been removed (18F8680 Family).
      18F8680, 18F8585, 18F6680, 18F6585:
      LATG.LATG5 has been removed (RG5 is input only).
      DDRG.RG5 has been removed (RG5 is input only).
      ( C18-508)
      Bits have been moved/removed in 18F1330 Family.
      18F1330, 18F1230:
      DDRA.RA5 has been removed (RA5 is input only).
      STKPTR.STKFUL has been moved from bit 6 to bit 7 (where it belongs).
      CONFIG2L.BORV<2:0> mask has changed from 0xC to 0x18 (corrected wrong mask value)
      ( C18-509)
      Bits have been moved/removed in 18F4321 Family .
      18F4321 only:
      Bits (HLVDL<3:0>, IVRST, VDIRMAG, LVDL<3:0>, LVV<3:0>, LVDEN, and BGST
      have been moved from OSCCON to HLVDCON where they belong.
      18F4321, 18F4221 only:
      CONFIG4L.ICPRT has been removed (reserved bit now hidden).
      18F2321, 18F2221 only:
      CCP1CON and CCP1CON have been removed (unimplemented on 28-pin devices).
      ( C18-510)
      Bits have been removed from 18F4450 Family.
      CONFIG4L.ICPRT has been removed
      ( C18-511)
      Bits have been renamed in 18F4580 Family.
      18F4580, 18F4480, 18F2580, 18F2480: Registers CANSTAT_RO0, RO1, RO2, RO3, RO4, RO5, RO6 RO7, RO8, RO9: bit OPMODE has been renamed to OPMODE0 bit REQOP1 has been renamed to OPMODE1 (note REQOP1 is in CANCON_RO0...CANCON_RO9 not CANSTAT) bit REQOP2 has been renamed to OPMODE2 (note REQOP2 is in CANCON_RO0...CANCON_RO9 not CANSTAT)
      ( C18-512)
      Bits have been renamed in 18F4680 Family.
      18F4680, 18F4585, 18F2680, 18F2585:
      Registers CANSTAT_RO0, RO1, RO2, RO3, RO4, RO5, RO6 RO7, RO8, RO9:
      bit OPMODE has been renamed to OPMODE0
      bit REQOP1 has been renamed to OPMODE1 (note REQOP1 is in CANCON_RO0...CANCON_RO9 not CANSTAT)
      bit REQOP2 has been renamed to OPMODE2 (note REQOP2 is in CANCON_RO0...CANCON_RO9 not CANSTAT)
      ( C18-513)
      Bits have been renamed in 18F4685 Family.
      18F4685, 18F4682, 18F2685, 18F2682:
      Registers CANSTAT_RO0, RO1, RO2, RO3, RO4, RO5, RO6 RO7, RO8, RO9:
      bit OPMODE has been renamed to OPMODE0
      bit REQOP1 has been renamed to OPMODE1 (note REQOP1 is in CANCON_RO0...CANCON_RO9 not CANSTAT)
      bit REQOP2 has been renamed to OPMODE2 (note REQOP2 is in CANCON_RO0...CANCON_RO9 not CANSTAT)
      ( C18-514)
      Bits have been removed in 18F4610 Family.
      18F4610, 18F4515, 18F4410, 18F2610, 18F2515, 18F2410:
      PORTB.DAD5, PORTB.DAD6, and PORTB.DAD7 have been removed (emulator only pin function).
      ( C18-515)
      Register has been removed in 18F4620 Family.
      18F4620, 18F4525, 18F2620, 18F2525:
      DEBUG register has been removed (FD4h is an unimplemented register).
      ( C18-516)
      Bits have been removed in 18F8490 Family.
      18F8490, 18F8390, 18F6490, 18F6390:
      PORTD has been removed (External memory is not supported on this family).
      PORTE has been removed (External memory is not supported on this family).
      ( C18-517)
      Bits have been removed in 18F8493 Family.
      18F8493, 18F8393, 18F6493, 18F6393:
      PORTD has been removed (External memory is not supported on this family).
      PORTE has been removed (External memory is not supported on this family).
      ( C18-518)
      Register has been removed in 18F14K22 Family.
      18F14K22, 18F13K22, 18LF14K22, 18LF13K22:
      EEADRH has been removed, family only has 256 bytes of data eeprom (handled by EEADR register).
      (data sheet is in error and will be updated in the future to remove the register)
      ( C18-519)
      Register has been removed in 18F14K50 Family.
      18F14K50, 18F13K50, 18LF14K50, 18LF13K50:
      EEADRH has been removed, family only has 256 bytes of data eeprom (handled by EEADR register).
      (data sheet is in error and will be updated in the future to remove the register)
      ( C18-520)
      Bits have been removed in 18F46K20 Family.
      18F26K20, 18F25K20, 18F24K20, 18F23K20:
      The following bits have been removed since they are not supported on 28-pin devices: SLRCON.SLRD, SLRCON.SLRE, ANSEL.ANS5, ANSEL.ANS6, ANSEL.ANS7, PIE1.PSPIE, PIR1.PSPIF, and IPR1.PSPIP
      ( C18-521)
      Registers have been removed from 18F85J90 Family.
      18F65J90, 18F64J90, 18F63J90:
      The following registers are not implemented on 64-pin packages so they have been removed: DDRH, DDRJ, TRISH, and TRISJ
      ( C18-522)
      Bits have been moved / removed in 18F87J10 Family).
      18F87J10, 18F86J15, 18F86J10, 18F85J15, 18F85J10, 18F67J10, 18F66J15, 18F66J10, 18F65J15, 18F65J10:
      PORTB.PGM has been removed (no PGM pin for these parts)
      PORTB.PGC has moved from bit 5 to bit 6 (PGC is bit 6 not 5)
      PORTB.PGD has moved from bit 6 to bit 7 (PGD is bit 7 not 6)
      18F67J10, 18F66J15, 18F66J10, 18F65J15, 18F65J10 Only Unify Issues:
      PORTD has been removed (no external memory support on 64-pin devices)
      PORTE has been removed (no external memory support on 64-pin devices)
      ( C18-523)
      Bits have been moved from 18F87J11 Family.
      18F87J11, 18F86J16, 18F86J11, 18F67J11, 18F66J16, 18F66J11:
      PORTB.PGC has moved from bit 5 to bit 6 (PGC is bit 6 not 5)
      PORTB.PGD has moved from bit 6 to bit 7 (PGD is bit 7 not 6)
      ( C18-524)
      Bit has been removed from 18F87J50 Family.
      18F87J50, 18F86J55, 18F86J50, 18F85J50, 18F67J50, 18F66J55, 18F66J50, 18F65J50:
      DDRF.RF1 has been removed (RF1 does not exist on this family).
    6. Fixed between v3.35 and 3.36:

      ( C18-489)
      Handling of enumerated type is incorrect.
      ( C18-525)
      Several bit field definitions in the header file do not match datasheet for 18F47J53 family.
      Remove: ODCON3 bit CTMUDS; ANCON1 bit VBG2EN; LATC bit LATC4; LATC bit LATC5; LATA bit LATA4; TRISC bit TRISC4; TRISC bit TRISC5.
      Correct names: CMSTAT bit C3OUT should be bit COUT3; PORTB bit CTEDG1 should be bit CTED1; PORTB bit CTEDG2 should be bit CTED2.
      ( C18-526)
      Several bit field definitions in the header file do not match datasheet for 18F47J13 family.
      Remove: ANCON0 bit PCFG5; ANCON1 bit VBG2EN.
      Correct names: CMSTAT bit C3OUT should be bit COUT3; PORTB bit CTEDG1 should be bit CTED1; PORTB bit CTEDG2 should be bit CTED2.
      ( C18-529)
      Several bit field definitions in the header file do not match datasheet for 18F87K22 family.
      Remove: ODCON3 bits CTMUREF0 and CTMUREF1; RTCVALH bits WAITE0, WAITE1, WAITM0..WAITM3, WAITB0, and WAITB1; TMR7L bits CAL0..CAL7.
      Add: ECCP3DEL (18F67K22 ONLY) bits P3DC0..P3DC6; and CCPR3 (18F65K22, 18F66K22 ONLY).
      Correct names: PORTA bit ULPWUIN> should be bit ULPWU and bit LVDIN should be bit HLVDIN; PORTB bit CCP2_PA2 should be bit CCP2_P2A; PORTC bit PA2_PORTC should be bit P2A_PORTC and bit PA1 should be bit P1A; PORTD bit SS2 should be bit NOT_SS2; PORTE bit PD2 should be bit P2D, bit PC2 should be bit P2C, bit RD should be bit NOT_RD, bit PB2 should be bit P2B, bit PC3 should be bit P3C, bit PC1 should be bit P1C, and bit PB1 should be bit P1B.
      ( UDBC-204)
      CONFIG1H (bit 5) should be unimplemented for 18F87K22 and 18F87K90 family
    7. Fixed between v3.34 and 3.35:

      ( C18-252)
      Problem with strncmppgm function.
    8. Fixed between v3.33 and 3.34:

      ( C18-56)
      Referencing a variable declared 'extern' with an initializer causes an internal failure.
      ( C18-109)
      A local variable declared 'rom' and 'extern' is disallowed when it should be permitted.
      ( C18-460)
      Inconsistency of PIC18 I2C peripheral library code during NACK detection in Slave mode.
      ( C18-463)
      WriteWord function in Flash support does not write data correctly.
    9. Fixed between v3.32 and 3.33:

      ( C18-454)
      Warning message for type mismatch should be reverted back to message level.
    10. Fixed between v3.31 and 3.32:

      ( C18-441)
      Message is generated instead of warning for type mismatch.
      ( C18-430)
      volatile does not force read.
      ( C18-297)
      Rand() function does not set bank properly before incrementing variable Seed in extended mode.
      ( C18-291)
      strlenpgm for small memory model corrupts byte on stack.
      ( C18-108)
      Add support for #message (or #warning) directive to preprocessor language.
    11. Fixed between v3.30 and 3.31:

      ( C18-359)
      Win 2000 incompatibility, problem with msvcrt.dll
  6. Devices Supported


    The MPLAB C Compiler for PIC18 MCUs (MCC18.EXE) is an ANSI C compiler for the PIC18 family of PIC microcontrollers. It currently supports the following PIC MCUs:
    PIC18C242       PIC18C252       PIC18C442       PIC18C452 
    PIC18C601       PIC18C658       PIC18C801       PIC18C858 
    
    PIC18F1220      PIC18F1230      PIC18F1320      PIC18F1330
    PIC18F13K22     PIC18F13K50     PIC18F14K22     PIC18F14K22LIN+      
    PIC18F14K50
    PIC18F2220      PIC18F2221      PIC18F2320      PIC18F2321      
    PIC18F2331      PIC18F23K20     PIC18F23K22     PIC18F2410 
    PIC18F242       PIC18F2420      PIC18F2423      PIC18F2431 
    PIC18F2439      PIC18F2450      PIC18F2455      PIC18F2458
    PIC18F248       PIC18F2480      PIC18F24J10     PIC18F24J11  
    PIC18F24J50     PIC18F24K20     PIC18F24K22 
    PIC18F2510      PIC18F2515      PIC18F252       PIC18F2520 
    PIC18F2523      PIC18F2525      PIC18F2539      PIC18F2550 
    PIC18F2553      PIC18F258       PIC18F2580      PIC18F2585 
    PIC18F25J10     PIC18F25J11     PIC18F25J50     PIC18F25K20     
    PIC18F25K22     PIC18F25K80
    PIC18F2610      PIC18F2620      PIC18F2680      PIC18F2682      
    PIC18F2685      PIC18F26J11     PIC18F26J13     PIC18F26J50
    PIC18F26J53     PIC18F26K20     PIC18F26K22     PIC18F26K80
    PIC18F27J13     PIC18F27J53 
    PIC18F4220      PIC18F4221      PIC18F4320      PIC18F4321
    PIC18F4331      PIC18F43K20     PIC18F43K22     PIC18F4410      
    PIC18F442       PIC18F4420 
    PIC18F4423      PIC18F4431      PIC18F4439      PIC18F4450
    PIC18F4455      PIC18F4458      PIC18F448       PIC18F4480 
    PIC18F44J10     PIC18F44J11     PIC18F44J50     PIC18F44K20     
    PIC18F44K22     PIC18F4510      PIC18F4515 
    PIC18F452       PIC18F4520      PIC18F4523      PIC18F4525 
    PIC18F4539      PIC18F4550      PIC18F4553      PIC18F458 
    PIC18F4580      PIC18F4585      PIC18F45J10     PIC18F45J11  
    PIC18F45J50     PIC18F45K20     PIC18F45K22     PIC18F45K80
    PIC18F4610      PIC18F4620      
    PIC18F4680      PIC18F4682      PIC18F4685      PIC18F46J11     
    PIC18F46J13     PIC18F46J50     PIC18F46J53     PIC18F46K20
    PIC18F46K22     PIC18F46K80     PIC18F47J13     PIC18F47J53     
    PIC18F6310       
    PIC18F6390      PIC18F6393      PIC18F63J11     PIC18F63J90
    PIC18F6410      PIC18F6490      PIC18F6493      PIC18F64J11     
    PIC18F64J90     PIC18F6520 
    PIC18F6525      PIC18F6527      PIC18F6585      PIC18F65J10 
    PIC18F65J11     PIC18F65J15     PIC18F65J50     PIC18F65J90
    PIC18F65K22     PIC18F65K80     PIC18F65K90  
    PIC18F6620      PIC18F6621      PIC18F6622      PIC18F6627 
    PIC18F6628      PIC18F6680      PIC18F66J10     PIC18F66J11
    PIC18F66J15     PIC18F66J16     PIC18F66J50     PIC18F66J55
    PIC18F66J60     PIC18F66J65     PIC18F66J90     PIC18F66J93 
    PIC18F66J94*+   PIC18F66K22     PIC18F66K80     PIC18F66K90     
    PIC18F6720      PIC18F6722      PIC18F6723      PIC18F67J10 
    PIC18F67J11     PIC18F67J50     PIC18F67J60     PIC18F67J90  
    PIC18F67J93     PIC18F67J94*+   PIC18F67K22     PIC18F67K90  
    PIC18F8310      PIC18F8390      PIC18F8393      PIC18F83J11
    PIC18F83J90     PIC18F8410      PIC18F8490 
    PIC18F8493      PIC18F84J11     PIC18F84J90
    PIC18F8520      PIC18F8525      PIC18F8527      PIC18F8585 
    PIC18F85J10     PIC18F85J11     PIC18F85J15     PIC18F85J50
    PIC18F85J90     PIC18F85K22     PIC18F85K90     PIC18F8620      
    PIC18F8621      PIC18F8622 
    PIC18F8627      PIC18F8628      PIC18F8680      PIC18F86J10 
    PIC18F86J11     PIC18F86J15     PIC18F86J16     PIC18F86J50
    PIC18F86J55     PIC18F86J60     PIC18F86J65     PIC18F86J72
    PIC18F86J90     PIC18F86J93     PIC18F86J94*+   PIC18F86K22     
    PIC18F86K90     
    PIC18F8720      PIC18F8722      PIC18F8723      PIC18F87J10
    PIC18F87J11     PIC18F87J50     PIC18F87J60     PIC18F87J72
    PIC18F87J90     PIC18F87J93     PIC18F87J94*+   PIC18F87K22     
    PIC18F87K90     PIC18F96J60     PIC18F96J65     PIC18F96J94*+
    PIC18F97J60     PIC18F97J94*+
    
    PIC18LF13K22    PIC18LF13K50    PIC18LF14K22    PIC18LF14K50 
    PIC18LF23K22    PIC18LF24J10    PIC18LF24J11    PIC18LF24J50    
    PIC18LF24K22    PIC18LF25J10
    PIC18LF25J11    PIC18LF25J50    PIC18LF25K22    PIC18LF25K80 
    PIC18LF26J11    PIC18LF26J13    PIC18LF26J50    PIC18LF26J53
    PIC18LF26K22    PIC18LF26K80 
    PIC18LF27J13    PIC18LF27J53    PIC18LF43K22    PIC18LF44J10
    PIC18LF44J11    PIC18LF44J50    PIC18LF44K22    PIC18LF45J10
    PIC18LF45J11    PIC18LF45J50    
    PIC18LF45K22    PIC18LF45K80    PIC18LF46J11    
    PIC18LF46J13    PIC18LF46J50    PIC18LF46J53    PIC18LF46K22 
    PIC18LF45K80    PIC18LF47J13    PIC18LF47J53    
    PIC18LF65K80    PIC18LF66K80 
    PICMCV20USB 
    

    *Note: Early adopter support has been added for these devices since last release

    +Note: These devices DO NOT have peripheral library support.

    THE PARTS LISTED ABOVE MAY NOT ALL BE COMMERCIALLY AVAILABLE.

  7. MPLAB C Compiler for PIC18 MCUs Documentation

    The following files are associated with this release and can be found in the <install_dir>\doc directory.:

    • MPLAB C18 C Compiler Getting Started (PDF)
    • PIC18 Configuration Settings Help (hlpPIC18ConfigSet.chm)
    • COFF File Format Help (hlpCOFFfile.chm)
    • MPLAB C18 C Compiler User's Guide Help (hlpC18ug.chm)
    • MPLAB C18 C Compiler Libraries (hlpC18Lib.chm)
    • Hardware Peripheral Library Function Documention found under the <install_dir>\doc\periph_lib directory.

    Documentation (in pdf format) is available from our web site: http://www.microchip.com/c18 however:

    • The information in the MPLAB C18 C Compiler User's Guide Help (hlpC18ug.chm) supersedes the information found in the MPLAB C18 C Compiler User's Guide (PDF) (DS51288 revision J) which can be found on the web site.
    • The information in the MPLAB C18 C Compiler Libraries (hlpC18Lib.chm) and the Hardware Peripheral Library Function Documentation found under the <install_dir>\doc\periph_lib directory supersede the information found in the MPLAB C18 C Compiler Libraries (PDF) (DS51297 revision F) which can be found on the web site.
  8. Installation and Upgrades

    MPLAB C Compiler for PIC18 MCUs requires the use of MPLINK Linker; MPLAB C18 v3.00 or later will require MPLINK Linker v4.00 or later. The latest version of MPLINK Linker is included with the installation.

    To verify correct installation of MPLAB C Compiler for PIC18 MCUs, 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 C Compiler for PIC18 MCUs, the setup program offers the user the ability to change several environment settings. The following options are provided:

    Environment Variables:

    • Add MPLAB C18 to PATH environment variable
      The directory of the compiler executables is added to the beginning of the current PATH environment variable.
    • Add MPASM Assembler to PATH environment variable
      The directory of the MPASM Assembler executable is added to the beginning of the current PATH environment variable.
    • Add header file path to MCC_INCLUDE environment variable
      The location of the header (.h) files is added to the beginning of the user's MCC_INCLUDE environment variable. MPLAB C18 uses this setting to search for header files.
    • Modify PATH and MCC_INCLUDE variables for all users
      The options listed above are applied to the machine environment variables instead of the user environment variables, so that they affect all users and not just the current user.
      This option only appears if the user running the installer has administrative rights.

    MPLAB IDE Configuration:
    The options below only appear if the user has a version of MPLAB IDE installed.

    • Update MPLAB IDE to use this MPLAB C18
      Configuration settings used by the MPLAB IDE to find MPLAB C18 will be updated to indicate the location of this release.
    • Update MPLAB IDE to use this MPLINK Linker, MPLIB librarian, and MPASM Assembler
      Settings used by MPLAB IDE to find the MPLINK Linker, MPLIB librarian, and MPASM Assembler will be updated to point to those in this release.
    • Update MPLAB IDE Help with MPLAB C18 documentation
      Documentation installed with MPLAB C18 will be made available from the Help menu of the MPLAB IDE.
      This option only appears if documentation is being installed.
    • Perform MPLAB IDE updates for all users
      The changes to the MPLAB IDE configuration are applied to the machine registry instead of that of the current user, so that they affect all users and not just the current user.
      This option only appears if the user running the installer has administrative rights.

    If MPLAB C18 is uninstalled, these changes to the IDE configuration will not be rolled back.

    If you have previously installed a Student, Demo, or Lite version of MPLAB C18 and you wish to upgrade your current installation, simply purchase and install the full Standard version - it will overwrite the other version. So, no license key is required.

  9. Using MPLAB C Compiler for PIC18 MCUs with the MPLAB IDE

    See the document "MPLAB C18 C Compiler Getting Started Guide" for a step-by-step tutorial on using MPLAB C Compiler for PIC18 MCUs 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.

  10. Known Problems

    The following are some of the known issues with MPLAB C18 v3.21. 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.

    SSR SUMMARY

    General


    ( C18-19 / 18487)
    With the compound assignment operators, the usual type conversions which are to be performed on the operands are not done correctly when the left operand is 8 bits in size.
    ( C18-39 / 20189)
    (non-extended mode only) Passing a static parameter to a function pointer in a structure should generate an error message, but instead generates an internal compiler error.
    ( C18-40 / 20359)
    There is a bug in the implementation of the scoping of typedef names.
    ( C18-45 / 20975)
    With integer promotions enabled, if the left operand of the >>= operator is negative, the result stored in the operand is incorrect.
    ( C18-50 / 21192)
    (non-extended mode only) The result of the %= operator where the left operand is a 24-bit or 32-bit rom variable is incorrect.
    ( C18-53 / 21261)
    (non-extended mode only) Calling a function pointer which has been converted from an object pointer generates an internal compiler error.
    ( C18-64 / 21514)
    (non-extended mode only) Using static parameters with a function which has a variable number of arguments is not supported, but does not generate a compile time error.
    ( C18-74 / 21634)
    The assignment of the address of an object in constant program memory to a pointer to non-constant data memory does not generate a diagnostic.
    ( C18-80 / 21693)
    Redefinitions of structure tags in nested scopes are not observed properly by MPLAB C18.
    ( C18-88 / 22091)
    String literals are placed in program memory and so must be assigned to variables of type 'rom char *'. However, assigning one to a pointer to data memory does not generate a diagnostic.
    ( C18-89 / 22147)
    Octal constants which contain an '8' or '9' do not generate a diagnostic. Instead, the code compiles quietly, and the value used for the constant is indeterminate.
    ( C18-106 / 22768)
    The redeclaration of a structure tag should generate an error, but does not.
    ( C18-115 / 23183)
    When the conditional (?:) operator is used with operands which are greater than 32 bits in size, an "irreducible tree" internal error may be generated.
    ( C18-126 / 23897)
    integer *= float-constant casts constant to integer before multiplication.
    ( C18-130 / 24130)
    A conflicting redefinition of type does not cause error or warning.
    ( C18-140 / 24481)
    Due to a COFF limitation, a greater than 16-bit relocation offset is calculated incorrectly at link-time.
    ( C18-166 / 26056)
    Unable to reduce tree for: if (local char * > parameter const rom far char * + constant)
    ( C18-183 / 27011)
    No error message generated for run time assignment to a const struct.
    ( C18-188 / 27455)
    The volatile qualifier is not applied to struct members.
    ( C18-281)
    Conditional expression involving bitfield arithmetic evaluated incorrectly.
    ( C18-285)
    Type-qualifier mismatch warning building vfprintf.c for small memory model.
    ( C18-286)
    No qualifier-mismatch warning assigning address of const to non-const pointer.
    ( C18-289)
    assertion on passing arguments to function pointer in static/overlay model.
    ( BIN18-3 / 22483)
    MPLIB librarian is unable to work with MPLAB C18 files compiled in the static overlay model.

    Inline Assembly


    ( C18-90 / 22170)
    Incorrect use of automatic local variables in inline assembly code does not generate a warning or error.
    ( C18-96 / 22559)
    Enumeration constants in expressions which are operands of inline assembly instructions can cause an internal error to be generated.

    Preprocessor


    ( C18-51 / 21252 / C18-160 / 25868)
    A macro invocation spanning more than one logical source file line may throw off line number information or cause the preprocessor to not output a line number, causing debugging difficulty in the MPLAB IDE.
    ( C18-81 / 21817)
    Preprocessor merging operator should take precedence over the stringization operator.
    ( C18-92 / 22522)
    The preprocessor may go into an infinite loop when expanding mutually recursive macros.
    ( C18-122 / 23717)
    Comments in a macro call may cause incorrect substitution or a syntax error.
    ( C18-124 / 23817)
    The preprocessor performs macro replacement within the text of a #error directive.
    ( C18-125 / 23827)
    Crash (after error message) for #elif with no preceding #if
    ( C18-128 / 24038)
    No error when #if does not have corresponding #endif and condition is true.
    ( C18-154 / 25409)
    Preprocessor evaluates expressions in discarded lines of an #ifdef expression.
    ( C18-169 / 26385)
    The preprocessor does not throw an error on finding "#elsif"
    ( C18-193 / 27540)
    A malformed expression in a #if preprocessor directive on the last line of a file with no terminating end of line character may cause the preprocessor to crash.
    ( C18-204 / 28101)
    Circular or recursive macro definitions can cause the preprocessor to take up all available CPU cycles and hang for a long time before giving an error.

    Libraries

    Note: See "Devices Supported" for the Note that shows which devices DO NOT have peripheral library support.

    ( C18-23 / 18624)
    The library routine 'atof' generates a result less precise than simply assigning a constant.

    Header Files


    None.

    User Error Screening


    None.

    SSR DETAILS

    General


    (C18-19 / 18487)
    With the compound assignment operators, the usual type conversions which are to be performed on the operands are not done correctly when the left operand is 8 bits in size. This can cause problems in these instances:

    -- With integer promotions enabled, the compound assignment division operator may return incorrect results on 8-bit operands when the left operand is signed and the right is unsigned. The workaround is to replace:
      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;
    
    (C18-39 / 20189) (non-extended mode only)
    Passing a static parameter to a function pointer in a structure should generate an error message, but instead generates an internal compiler error.
    For example:
      struct { void (*f) (static int x); } S;
      void main (void) { S.f (1); }
    
    (C18-40 / 20359)
    There is a bug in the implementation of the scoping of typedef names.
    The following example generates a syntax error:
      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.

    (C18-45 / 20975)
    With integer promotions enabled, if the left operand of the >>= operator is negative, the result stored in the operand is incorrect.
    For example, 'x' should be end up with -1, but instead ends up with 1:
      signed char x;
      x = 0x80;
      x >>= 7; /* 'x' should be -1, but is 1 instead */
    
    The integer promotions are not performed on 'x'.

    (C18-50 / 21192) (non-extended mode only)
    The result of the %= operator where the left operand is a 24-bit or 32-bit rom variable is incorrect. For example:
      rom short long x;
      void main (void)
      {
        short long y;
        x = 1025;
        y = x %= 2; /* 'x' correctly receives 1, but 'y' does not */
        ...
    
    (C18-53 / 21261) (non-extended mode only)
    Calling a function pointer which has been converted from an object pointer generates an internal compiler error. For example:
      unsigned long x[4];
      void main (void) { ((void (*)(void))x)( ); }
    
    (C18-64 / 21514) (non-extended mode only)
    Using static parameters with a function which has a variable number of arguments is not supported, but does not generate a compile time error. Instead, a link time error is emitted which may not be comprehensible:
      Error - could not find definition of symbol '_foo:101' ...
    
    Such would be the error message if the function in question is called 'foo'.

    (C18-74 / 21634)
    The assignment of the address of an object in constant program memory to a pointer to non-constant data memory does not generate a diagnostic. For example:
      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.

    (C18-80 / 21693)
    Redefinitions of structure tags in nested scopes are not observed properly by MPLAB C18. For example:
      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.

    (C18-88 / 22091)
    String literals are placed in program memory and so must be assigned to variables of type 'rom char *'. However, assigning one to a pointer to data memory does not generate a diagnostic. For example:
      char *s = "hello world";
    
    Any references through 's' will result in indeterminate behavior.

    (C18-89 / 22147)
    Octal constants which contain an '8' or '9' do not generate a diagnostic. Instead, the code compiles quietly, and the value used for the constant is indeterminate.

    (C18-106 / 22768)
    The redeclaration of a structure tag should generate an error, but does not. For example:
      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.

    (C18-115 / 23183)
    When the conditional (?:) operator is used with operands which are greater than 32 bits in size, an "irreducible tree" internal error may be generated. For example:
      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.

    (C18-126 / 23897)
    integer *= float-constant casts constant to integer before multiplication.
    For example:
      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;
    
    (C18-130 / 24130)
    Conflicting redefinition of type does not cause error or warning.
    For example:
      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'
    
    (C18-140 / 24481)
    Due to a COFF limitation, a greater than 16-bit relocation offset is calculated incorrectly at link-time.

    Microchip's Common Object File Format (COFF) contains a limitation in the relocation entry, which is the structure that implements the dynamics of relocation. In Microchip's COFF, the offset to add to the base address of the symbol is stored in the relocation entry. This differs from the System V relocation data in which the offset is stored in the location being relocated to. This difference is necessary because Microchip relocations are not restricted to just filling in an address + offset value into the data stream, but also to do simple code modifications. The limitation comes from the fact that this offset is defined as a short, which dictates that offsets may be no larger than 16-bit.
    The following example shows the side effect of this limitation:
      #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=21
    
    Note that the r_offset field reflects an offset of -32k instead of +32k.

    A workaround is to use code for which the compiler will evaluate the offset at run-time.
    For example:
      void foo( void )
      {
        varptr = &var;
        varptr += 0x8000;
      }
    
    (C18-166 / 26056)
    Unable to reduce tree for if (local char * > parameter const rom far char * + constant)

    For both extended and non-extended modes, the following function:
      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 tree
    
    The 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.

    (C18-183 / 27011)
    No error message generated for run time assignment to a const struct.
    For example, the code:
      typedef struct
      {
              int b;
      } typeB;
    
      const typeB objB;
    
      void fB_type( )
      {
              objB.b = 1;
      }
    
    does not generate an error.

    (C18-188 / 27455)
    The volatile qualifier is not applied to struct members.
    For the following source code:
      struct
        {
          unsigned char aaa;
          volatile unsigned char bbb;
        } flags;
    
    the volatile qualifier on the second member of the struct 'flags' is ignored.

    Workaround:
    Apply the volatile qualifier to the entire struct.
      struct
        {
          unsigned char aaa;
          volatile unsigned char bbb;
        } volatile flags;
    
    (C18-281)
    Conditional expression involving bitfield arithmetic evaluated incorrectly.

    For the following source code
    struct {
     unsigned	b1:1;
     unsigned	b2:1;
     unsigned	b3:1;
     unsigned	b4:1;
    } Test;
    
    char Signal (void)
    {
     while(1);
     return 1;
    }
    
    volatile unsigned char testval;
    void main (void)
    {
     Test.b1 = 1;
     Test.b2 = 1;
     Test.b3 = 1;
     Test.b4 = 1;
    
     testval = Test.b1 + Test.b2 + Test.b3;
    
     /* Expected false, Actual true */
     if (Test.b1 + Test.b2 + Test.b3 == 1)   /* line 26 */
     Signal();
     
     /* Expected false, Actual false */
     if (Test.b1 + Test.b2 + Test.b3  == 2) 
     Signal();
     
     /* Expected false, Actual false */
     if (!(Test.b1 + Test.b2  + Test.b3  - 1)) 
     Signal();
     
     while(1);
    }
    
    the first 'if' statement incorrectly evaluates to TRUE. The related generated code is
    mcc18 -s test.c -O-
    ...
      43(  26): movlb high( Test )
      44(  26): movf Test, 0, 1
      45(  26): andlw 1
      46(  26): addwf __tmp_0, 0, 0
      47(  26): addwf __tmp_0 + 1, 0, 0
      48(  26): bz 1                             //  <--- Why compare with zero?
      49(  26): rcall Signal, 0
    
    The workaround for this SSR is to cast the left hand side of the comparison to (unsigned char) as following
      if ((unsigned char) Test.b1 + Test.b2 + Test.b3 == 1)   /* line 26 */
    
      signal()
    
    (C18-285)
    Type-qualifier mismatch warning building vfprintf.c for small memory model.
    1) Update the batch files to use -ms and _SMALL_.
    2) Update the header files to define MEM_MODEL near.
    3) Run makeall.bat.
    BUILDING EXTENDED MODE LIBRARIES
    Building startup modules...
    Installing startup modules...
    Building library modules...
    ...math module... 
    ...standard C library module...
    C:\MCC18\src\extended\stdclib\vfprintf.c:268:Warning [2066] type qualifier mismatch in assignment
    ...delay module...
    Installing library...
    
    The code shows

    string.h
    /* Change this to near (or omit altogether) if building small memory model
     * versions of the libraries
     */
    #define MEM_MODEL near
    
    /** @name strlenpgm
     * The {\bf strlenpgm} function performs a {\bf strlen} where {\bf s}
     * points to program memory.
     * @param s pointer to object in program memory
     */
    sizerom_t strlenpgm (auto const MEM_MODEL rom char *s);
    
    vfprintf.c
    int
    vfprintf (auto FILE *handle, auto const rom char *f, auto va_list ap)
    {
      unsigned char c;
      int count = 0;
    
      for (c = *f; c; c = *++f)
        {
          if (c == '%')
            {
              unsigned char flags = 0;
              unsigned char width = 0;
              unsigned char precision = 0;
              unsigned char have_precision = 0;
              unsigned char size = 0;
              unsigned char space_cnt;
              unsigned char cval;
              unsigned long larg;
              far rom char *romstring;
    
    /* ... Removed code ... */
    
                case 'S':
                  if (size == _FMT_SHLONG)
                    romstring = va_arg (ap, rom far char *);
                  else
                    romstring = (far rom char*)va_arg (ap, rom near char *);
                  n = strlenpgm (romstring);                      /* line 268 */
    
    Passing a far pointer to a function expecting a near pointer should be ok, but our library should really build without warnings.

    (C18-286)
    No qualifier-mismatch warning assigning address of const to non-const pointer.

    For the following source code
    char* pdromU8;
    const char cdromU8;
    
    void funct (void)
    {
      pdromU8 = &cdromU8;   /* Expect warning */
    }
    
    the compiler should emit a qualifier-mismatch warning because the 'const' is lost.

    (C18-289)
    Assertion on passing arguments to function pointer in static/overlay model.

    This only happens in traditional mode.

    When a function pointer is declared in typedef struct without explicitly declaring its arguments as auto, at compile time with -scs or -sco, the compiler asserts failier on the line that the function pointer is called.

    The problem is that compiler should send diagnostic at the place of declaration of function pointer when -scs or -sco are used, to tell the user that they must declare the arguments explicitly as auto.

    (BIN18-3 / 22483)
    MPLIB librarian is unable to work with MPLAB C18 files compiled in the static overlay model.
    For example:
      int add( int a, int b )
      {
        int c;
        c = a + b;
        return c;
      }
    
    Compiled with:
      mcc18 test.c -sco
    
    Then placed in an archive containing only this file:
      mplib -c test.lib test.o
    
    MPLIB librarian is unable to list the files in the archive.
      mplib -t test.lib
    
    Gives 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 Linker also gives an error saying it could not read the string table.


    Inline Assembly


    (C18-90 / 22170)
    Incorrect use of automatic local variables in inline assembly code does not generate a warning or error.
    Automatic local variables, when used in inline assembly expressions, are given a value which is their offset from the frame pointer.
    For example, the following code demonstrates the proper accessing of stack-based variable 'a' using its value in PLUSW2 addressing.
    It then demonstrates improper accessing of stack variable 'b' by attempting to reference it using direct mode addressing.
      #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.

    (C18-96 / 22559)
    Enumeration constants in expressions which are operands of inline assembly instructions can cause an internal error to be generated.
    The workaround is to use integer constants instead.

    Preprocessor


    (C18-51 / 21252 / C18-160 / 25868)
    A macro invocation spanning more than one logical source file line may throw off line number information, or cause the preprocessor to not output a line number, causing debugging difficulty in the MPLAB IDE.
    For example:
      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.
    Additionally, stepping through the source code may not follow the expected sequence of execution. The workaround is to use the line splice character after each macro argument:
      void main (void)
      {
        int x;
    
        f (arg1,\
           arg2,\
           arg3);
        ...
        x++;
    
    (C18-81 / 21817)
    Preprocessor merging operator should take precedence over the stringization operator.
    For example:
      #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" ;
    
    (C18-92 / 22522)
    The preprocessor may go into an infinite loop when expanding mutually recursive macros.
    For example:
      #define x (4 + y)
      #define y (2 * x)
      void main (void) { y; }
    
    causes the preprocessor to run indefinitely.

    (C18-122 / 23717)
    Comments in a macro call may cause incorrect substitution or a syntax error.
    For example:
      #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:

    A comment following the last argument in a macro invocation may cause a syntax error. For 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.

    (C18-124 / 23817)
    The preprocessor performs macro replacement within the text of a #error directive.

    Example source code:
      #define FOSC 1800
      #error "FOSC is 1800"
    
    Preprocessor command line:
      cpp18 preproc-1.c
    
    Preprocessor output:
      #line 1 "preproc-1.c"
      #line 2 "preproc-1.c"
      preproc-1.c:2: "1800 is 1800"
    
    (C18-125 / 23827)
    Crash (after error message) for #elif with no preceding #if For example:
      ...
      /* no #if here */
      #elif defined (_FOO_)
      #endif
    
    (C18-128 / 24038)
    No error is given when #if does not have corresponding #endif and the condition is true
    For example:
    This gives a syntax error:
      #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.

    (C18-154 / 25409)
    Preprocessor evaluates expressions in discarded lines of an #ifdef expression.
    For example:
      #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.

    (C18-169 / 26385)
    The preprocessor does not throw an error on finding "#elsif"
    The following code:
      #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.

    (C18-193 / 27540)
    A malformed expression in a #if preprocessor directive on the last line of a file with no terminating end of line character may cause the preprocessor to crash.
    For example:
      #define symbol
      #if symbol /* end of file */
    
    causes the preprocessor to crash.

    Workaround: Terminate the source file by adding a blank last line.
    The preprocessor will display an error without crashing.

    (C18-204 / 28101)
    Circular or recursive macro defnitions can cause the preprocessor to take up all available CPU cycles and hang for a long time before giving an error.
    For example, the following code:
      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
    

    Libraries

    Note: See "Devices Supported" for the Note that shows which devices have peripheral library support.

    (C18-23 / 18624)
    The library routine 'atof' generates a result less precise than simply assigning a constant. For example:
      float a, c;
      char b[] = ".15625";
      void main ( )
      {
        a = atof (b);
        c = .15625;
      }
    
    The representation of 'c' is 0x7c200000 and 'a' is 0x7c1fffff.

    Header Files


    None.

    User Error Screening


    None.

  11. Contributors

    Microchip gratefully acknowledges the contributions of the following to the development of MPLAB C Compiler for PIC18 MCUs.

    Daniel Madill, Quanser Consulting --
    December 2000, Optimizations to fixed point divide library routines.

  12. Customer Support


    Microchip provides online support via our home page at:
    http://www.microchip.com

    Technical support is available through the web site at:
    http://support.microchip.com

    A forum for discussion of Microchip products and tools is available at:
    http://forum.microchip.com