Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Question about HI-TECH C.

Status
Not open for further replies.

blakes7

Newbie level 6
Joined
Sep 16, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,405
I have complied a single file from the HI-TECH C ../samples folder. Here is the source file description.

/* Example code for using timer0 on a 16F84
Just sets up a 1 second interrupt and increments a variable */

When I went to build this single file project with MPLAB IDE HI-TECH C plug in I got an error saying that OPTION is not defined. I looked in the pic16f84.h and pic16f84a.h files in the compiler include directories and found OPTION_REG defined and not OPTION. Is there a header file in HI-TECH C that has OPTION defined ?

Also the compiler manual says that you need to include the file htc.h in every C program so that the program will have access to the SFRs for the particular PIC.
I looked in the htc.h file but I cannot see how my pic's header file is included through this file. Can someone please explain how htc.h works ?

HTC.H header contents

#ifndef _HTC_H_
#define _HTC_H_

/* Definitions for _HTC_EDITION_ values */
#define __LITE__ 0
#define __STD__ 1
#define __PRO__ 2

/* common definitions */

#define ___mkstr1(x) #x
#define ___mkstr(x) ___mkstr1(x)

/* HI-TECH PICC / PICC-Lite compiler */
#if defined(__PICC__) || defined(__PICCLITE__)
#include <pic.h>
#endif

/* HI-TECH PICC-18 compiler */
#if defined(__PICC18__)
#include <pic18.h>
#endif

/* HI-TECH dsPICC compiler */
#if defined(__DSPICC__)
#include <dspic.h>
#endif

/* HI-TECH C for PIC32 */
#if defined(__PICC32__)
#include <pic32.h>
#endif

#endif

Thanks.
 

spudboy488

Full Member level 5
Joined
Oct 10, 2012
Messages
272
Helped
69
Reputation
140
Reaction score
75
Trophy points
1,308
Activity points
3,058
<htc.h> is the top level where it determines what family of PIC is the target. It gets that from the MPLAB IDE. From there, it will load another include file (in your case, <pic.h> which will also load <chip_select.h>) which will load the include for the specific part which it also gets from the IDE. Ultimately, the include for the part gets loaded. In my case, C:\Program Files\HI-TECH Software\PICC\9.83\include\pic16f84.h

To further complicate things, some time back, HiTech changed how they handled registers in the include files. The OPTION reg is now called OPTION_REG. Your sample code may not have been updated. You could either change all the register names (which you should do if you are going to write some stuff for future use) or set a flag for the compiler to use the legacy headers (which for just running samples would be fine). Add the following ABOVE the <htc.h> include:

#define _LEGACY_HEADERS
#include <htc.h>

That should do it.
 

blakes7

Newbie level 6
Joined
Sep 16, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,405
Hi spudboy488,

I added the define for _LEGACY_HEADERS and the project compiled successfully.
Thanks for your help.

- - - Updated - - -

Hi spudboy488,

I have just one more question out of curiosity.
If you can figure it out, what do these lines in <htc.h> do ?

#define ___mkstr1(x) #x
#define ___mkstr(x) ___mkstr1(x)

Thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top