Microchip MPLAB C18

212,770pages on
this wiki
Add New Page
Add New Page Discuss this page0

Microchip MPLAB C18 is a C-Compiler. It supports all PIC18 Devices. It can run standalone from the Commandline or in the Microchip MPLAB IDE.

Students Edition

There is a free Students Edition, which must not be used for commercial projects. It has only 2 minimal restrictions:

In particular for hobbyists this restrictions are nonserious. Many other compilers do not have this features at all.

Discrepancies ANSI-C89/90

Inline Assembler

If only 1 Assembler instruction is included into the C-Code, then the whole optimizing will be deactivated.

Integral Promotion

Resulting Problems With Constants

Other Resulting Problems And Workarounds

Anonym Structures in Unions

An Union supports anonym (unnamed) structures, which helps to keep names short and which is an extension to the ANSI-C89/90 Standard.

Example ANSI complient

union {

     unsigned char x;
     unsigned char y;
  } placeholder2;

  unsigned int z;

} placeholder1;

Access of an element: unsigned int w; placeholder1.placeholder2.a = 0xE5; placeholder1.placeholder2.b = 0x3B; w = placeholder1.z;

vs. Example anonym structures

union {

     unsigned char x;
     unsigned char y;
  }; // no name!

  unsigned int z;

} placeholder;

Access of an element: unsigned int w; placeholder.x = 0xE5; placeholder.y = 0x3B; w = placeholder.z;

Bit Variable

typedef struct {

   unsigned flag0:1;
   unsigned flag1:1;
   unsigned flag2:1;
   unsigned flag3:1;
   unsigned flag4:1;
   unsigned flag5:1;
   unsigned flag6:1;
   unsigned flag7:1;

} Byte;

Also on Fandom

Random wikia