# What are chip name macros are available in the HI-TECH C compiler?

I am using the HI-TECH C compiler for the PIC16 Microcontroller, and I would like to conditionally compile different chunks of code depending on which specific microcontroller has been selected.

I know you can conditionally compile code with something like:

#if defined(MACRO1)
... compile this code ...
#elif defined(MACRO2)
... compile this code ...
#endif


What I need to know is what pre-defined macros are available in the HI-TECH C compiler that will let me select on the specific microcontroller?

• That depends on which toolchain you're using. – Majenko Sep 12 '11 at 18:02
• I am using HI Tech C compiler. – rashid Sep 12 '11 at 18:06

Page 98 of the HITEC C Manual lists all the pre-defined macros.

One of the entries is:

_CHIPNAME To indicate the specific chip type selected, e.g., _16F877

so you have, as other examples:

• _16F88
• _16F84A
• _16F505
• _16F777
• _16F1823
• ...

etc.

If you asking about conditionally compiling code for different PICs using the defined name, you can use the predefined _CHIPNAME macro mentioned on page 106 of the 9.81 manual.
Or you can use the family (e.g _PIC12, _PIC14, _PIC14E as mentioned in the same table) or simply define your own.

It seems like you want conditional assembly (or compilation) depending on the target chip, although your example is somewhat unclear. I don't think you can put DEFINE in the target of a #IF as in your first case, and you appear to be testing for the same thing in both cases.

In any case, there is a symbol defined for the specific PIC model number as specified on the MPASMWIN command line or with the LIST directive. The model-specific include files have a check in them to make sure the right model is selected to match the include file. You can therefore write:

#ifdef __18f2520
;code here is only included when target is PIC 18F2520
#endif
• I think that's a typo. If you read the entire code snippet you'll see the second one is defined(...) which is perfectly valid. – Majenko Sep 12 '11 at 18:30
• And the "pic16macro" is a placeholder for the target of the question: "what should the OP be putting in there?" – Majenko Sep 12 '11 at 18:34
• @Majenko: The original question was very poorly written so that it was a bit confusing. I see Kevin has now fixed this, and added the very important information that HITECH C is being asked about. I am not familiar with that compiler, so I thought there might have been relevance to DEFINE in one place and DEFINED in another. You really don't expect two errors in a 4 line example specifically written to illustrate your question. Couldn't the OP have bothered to proofread what he wrote!? – Olin Lathrop Sep 12 '11 at 19:54