• AVR Freaks

LockedWhere are CONFIG options defined?

Page: 123 > Showing page 1 of 3
Author
sjb741
Super Member
  • Total Posts : 849
  • Reward points : 0
  • Joined: 2010/01/25 08:45:39
  • Location: 0
  • Status: offline
2012/08/29 02:26:06 (permalink)
0

Where are CONFIG options defined?

Testing XC8 with a PIC16F873A I was using this syntax to set the fuses:

   __CONFIG
   (
       FOSC_XT &
       WDTE_OFF &
       CP_OFF &
       DEBUG_ON &
       WRT_OFF &
       CPD_OFF &
       LVP_OFF &
       BOREN_ON &
       PWRTE_OFF
   );

In v1.01, the constants were defined in pic16f873a.h. For example:
// XT oscillator
#define FOSC_XT                                             0xFFFD

Now they are not - and a text search of all .h files under "C:\Program Files\Microchip\xc8\v1.10" failed to locate their definition.

Of interest, the above config 'compiles' with no warnings whether or not I check "Use CCI sysntax" (build options/Compiler).

Questions:
(1) Where are DEBUG_ON etc defined in v1.10?
(2) Why no warnings in CCI mode - which requires this style: #pragma config WDTE=ON, FOSC=XT, CPD=ON?
(3) Where are the CCI-style macros defined - how do I find out the existence of options such as "WDTE"?
#1

46 Replies Related Threads

    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 03:02:37 (permalink)
    0
    Hi,
     
    I think with XC8 you have to use the #pragma config statement now.
     
    I might be wrong as I'm new to this game. I certainly had to change some examples written for C18 to this type of code for config fuses.
     

    #include <xc.h>

    #pragma config MCLRE=ON
    #pragma config CP=OFF
    #pragma config CPD=OFF
    #pragma config BOREN=OFF
    #pragma config WDTE=OFF
    #pragma config PWRTE=OFF
    #pragma config FOSC=INTRCIO

     
    Regards
     
    Garry

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #2
    sjb741
    Super Member
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2010/01/25 08:45:39
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 03:30:08 (permalink)
    0
    Hi,
    OK thanks. The info I'd wanted is here (for the style you mention)
     
    file:///C:/Program%20Files/Microchip/xc8/v1.10/docs/chips/16f873A.html
     
    I guess Microchip removed the definitions I had been using to 'discourage' old-style CONFIG setting - it does still compile though.
    post edited by sjb741 - 2012/08/29 03:51:52
    #3
    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 04:25:17 (permalink)
    0
    I was working through a demo program that was supposed to have been converted from C18 to XC8 and it kept failing due to the syntax of the config fuses.
     
    The chip I'm using is a PIC12F629
     
    INTRCIO was the stumbling block for me as well as I couldn't find any reference to it in the data sheet
     
    in XC8 most of the chip dependant references is handled by the #include <xc.h> statement, which then refers to many other headers
     
    xc.h -> htc.h -> pic_chip_select.h -> pic12f629.h
     
    I still can't see where INTRCIO comes from
     
    In the data sheet it can be seen there are two internal clock options
     
    bit 2-0 FOSC<2:0>: Oscillator Selection bits 
    101 = INTOSC oscillator 
    100 = INTOSCIO oscillator 
     
    Both INTOSC and INTOSCIO produce a compile error.
     
    I can't verify if the code works as in typical MPLAB X style it will not see either of my two programmers on my Apple MacBook
     
     
     
     
     

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #4
    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 04:28:52 (permalink)
    0
    Good find...
     
    A bit of a ball breaker for anyone writing example files etc. if the formatting and naming keeps changing let alone someone like me trying to learn this stuff.
     
    Regards
    Garry

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #5
    kevcon
    Super Member
    • Total Posts : 568
    • Reward points : 0
    • Joined: 2011/09/16 07:34:49
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 06:00:14 (permalink)
    0
    @BigGaz - Look at the pic12f6x.h towards the bottom, the #defines your are looking for are there
    There is no INTRCIO mode but there is an RCIO mode.
     
     
    As far as the __CONFIG( ) goes it still woks on everything I have used of late.
    post edited by kevcon - 2012/08/29 06:04:17
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 19148
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 12:00:03 (permalink)
    0
    1. Either syntax is acceptable.
    2. Yes they keep changing them in their quest to automate an be uniform. (quest in Progress)
    3. The CONFIG Names are no longer in the Header file.  They are in a database file now.  The best place to look now (And I could be Wrong) is the the Display Config in MPLab
     
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 19148
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 12:03:32 (permalink)
    0
    (1) Where are DEBUG_ON etc defined in v1.10?
     
    You are not supposed to set Debug, the IDE handles it.  It was removed a while ago.
    #8
    meikled
    Super Member
    • Total Posts : 556
    • Reward points : 0
    • Joined: 2006/01/11 20:12:06
    • Location: Sydney, Australia
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 16:17:28 (permalink)
    +1 (1)
    BigGaz

    A bit of a ball breaker for anyone writing example files etc.


     
    Yes, that's me!  I thought I'd gone through and revised all my C tutorials for XC8, updating all the examples to use the newer bitfield style (e.g. PORTAbits.RA0) instead of the now-deprecated HI-TECH bit definitions (e.g. RA0).
    But I missed the fact that they also consider the __CONFIG() macro to be "legacy", and that we're supposed to use #pragmas instead.
    See my posts in this thread: http://www.microchip.com/forums/m672076.aspx
     
    It's interesting though that their own documentation hasn't caught up with the changes.  The XC8 v1.10 manual states, on page 313, documenting __CONFIG(), that "These masks can be found in the chip-specific header files included via <xc.h>."  Yet that's no longer true.
     
    I'm not going to go back and change all my 100 or so examples yet again, but I updated the explanation into lesson 1 for both the baseline and mid-range C tutorials to mention configuration pragmas and to tell people to look in pic_chipinfo.html for the config symbols.
     
    By the way, it seems that the symbols are effectively the same between the #pragma and __CONFIG() versions.
    E.g. "MCLRE = ON" translates to "MLRE_ON"  So, even if you still use the __CONFIG() form, you can consult pic_chipinfo.html to figure out what symbols to use - just change the " = " to a "_", and "&" them instead of using a "," separated list.
     
    The #pragma config version is certainly nicer.  It's just such a pain to have to continually revise my tutorials!
     
     
    #9
    meikled
    Super Member
    • Total Posts : 556
    • Reward points : 0
    • Joined: 2006/01/11 20:12:06
    • Location: Sydney, Australia
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 16:21:22 (permalink)
    0
    kevcon

    @BigGaz - Look at the pic12f6x.h towards the bottom, the #defines your are looking for are there
    There is no INTRCIO mode but there is an RCIO mode.


    You're talking about a legacy header, which we're not "supposed" to use any more.  There is no pic12f6x.h in the main include directory in XC8.
     
    #10
    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 16:30:49 (permalink)
    0
    NKurzman

    1. Either syntax is acceptable.
    2. Yes they keep changing them in their quest to automate an be uniform. (quest in Progress)
    3. The CONFIG Names are no longer in the Header file.  They are in a database file now.  The best place to look now (And I could be Wrong) is the the Display Config in MPLab


    Hi,
     
    I had a poke about after your valued comments and found the config bits display. I found it under Window -> PIC Memory View -> Configuration Bits.
     
    From here I right clicked within the display window and was able generate source code
     
    __CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & CP_OFF & CPD_OFF);

     
    The strange part is I pasted the code into MPLAP X and it complains. It does compile without issue, but IDE complains "unexpected token: ("
     
    Regards Garry
     

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 19148
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 16:59:09 (permalink)
    0
    MPLab X is reported to complain about valid code.  The common advice is to ignore MPLab X if the compiler is happy and the code is working.
    #12
    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/29 17:06:49 (permalink)
    0
    Thanks Dave,
     
    I find your examples great to work through. I bet it's a real ball breaker having to keep all the example fresh.
     
    I look forward to see some new examples when you have time and when I have worked my way through all of them. Thats if MPLAB X and XC8 gotcha's don't kill me first.
     
    Currently having a ping pong session with Microchip support, we can't seem to get my copy of MPLAB X V1.30 to see my two programmers on my Mac. Hopefully we will get a solution and I can test some of the code in real hardware.
     
    Thanks again Dave and keep up the good work.

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #13
    sjb741
    Super Member
    • Total Posts : 849
    • Reward points : 0
    • Joined: 2010/01/25 08:45:39
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/30 01:00:55 (permalink)
    0
    Re: "You are not supposed to set Debug, the IDE handles it.  It was removed a while ago."  
    That's useful to know. No doubt in a 'readme' somewhere. Do you have reference please?
     
    Re: "MPLab X is reported to complain about valid code."
    I can't wait not to try it out!
    post edited by sjb741 - 2012/08/30 01:18:23
    #14
    mad_c
    Super Member
    • Total Posts : 1289
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re:Where are CONFIG options defined? 2012/08/30 15:15:41 (permalink)
    0
    Hi,
     
    Assuming you are using the latest 1.10 compiler, go to the docs directory. There you will find two files pic_chipinfo.html and pic18_chipinfo.html. Open whichever is appropriate and click on the chip you are using. This will show you all the symbols and example.
     
    Jeff.
    #15
    Aeroengineer1
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2010/09/09 16:23:49
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/09/05 14:57:26 (permalink)
    0
    I too had to go looking for these files, and what was nice is that in C18, I could find these in the help files.  I would like to suggest that this be implemented for XC8 as well.
     
    Adam
    #16
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/09/05 20:01:57 (permalink)
    0
    Docs directory?  I did a full system search for pic_chipinfo.html, found nothing.  Do I have to download it from someplace on Mchip?
    #17
    BigGaz
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2012/08/19 14:33:18
    • Location: Worcester, UK
    • Status: offline
    Re:Where are CONFIG options defined? 2012/09/06 04:09:27 (permalink)
    +1 (1)
    Hi Tom,
    On my Mac they are located in applications/micrchip/xc8/v1.10/docs/
     
    On windows I would guess it would be something like c:\program files\microchip\xc8\v1.10\docs

    IDE: MPLAB X 1.30 Compilers: C18 V3.40 Lite, XC8 V1.10 Free Mode
    #18
    NKurzman
    A Guy on the Net
    • Total Posts : 19148
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/09/06 10:03:18 (permalink)
    0
    Do You Have Version V1.10?
    #19
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:Where are CONFIG options defined? 2012/09/06 10:31:04 (permalink)
    +1 (1)
    I do have v. 1.1, I also have Windows <expletive deleted> 7.  I found the file, search misses it.
     
    #20
    Page: 123 > Showing page 1 of 3
    Jump to:
    © 2021 APG vNext Commercial Version 4.5