1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Clarification on the header file

Discussion in 'Microcontrollers' started by elecLear78, Jul 14, 2017.

  1. elecLear78

    elecLear78 Member

    Joined:
    Jul 16, 2013
    Messages:
    226
    Likes:
    1
    Location:
    india
    I have seen in many microchip programs the following code
    Code (text):

    #if defined(__dsPIC33F__)
    #include "p33Fxxxx.h"
    #elif defined(__PIC24H__)
    #include "p24Hxxxx.h"
    #endif
     
    But where are these __dsPIC33F__ or __PIC24H__ will be defined. In which file should I look into?
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE
    With XC8/16/32 compilers, you only need XC.h as the processor type is obtained from the IDE and then XC8 /16/32 then produces an AS file ( assembly startup ) which defines the processor..

    Most compilers used to allow ( and still do ) the inclusion of the correct header... XC8 and MikroC both do not need this to be defined..
     
    • Like Like x 1
  3. elecLear78

    elecLear78 Member

    Joined:
    Jul 16, 2013
    Messages:
    226
    Likes:
    1
    Location:
    india
    So in case if i import any sample project i should select the correct controller for that project then it automatically includes that header. Am i correct?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    ONLINE

    Like I said... XC8 and MikroC allow automatic processor selection... I can't assume you are using a specific compiler / IDE.. MPIDE will pass the processor type to the compiler.. If you just include XC.H then it will auto detect. However! You can just specify the header by name.. ie.. #include <p24Hxxxx.h> and it will be found.. This is to simplify the coding process to the masses..
     

Share This Page