CONFIG Statement

Discussion in 'Embedded Systems and Microcontrollers' started by SteveO, Nov 17, 2009.

  1. SteveO

    Thread Starter Active Member

    May 15, 2008
    33
    0
    Hi all,

    Thanks for the help on my previous issue. I am trying to implement the CONFIG statement at the start of my code and it seems no matter which way I try to use it it gives me a mass load of errors/warnings when I try to build. Anyone have any ideas where I should start? I'm using Hi-tech C Compiler and MPLAB to do the programming.

    Thanks a bunch.
     
  2. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    How about posting the first few lines of your code? Use the code tags.

    John
     
  3. SteveO

    Thread Starter Active Member

    May 15, 2008
    33
    0
    Sounds fair. lol. So I've just recently started playing with PIC's and have created a simple blinking LED program.
    Code ( (Unknown Language)):
    1. #include <htc.h>
    2. #define _XTAL_FREQ 4000000
    3. //CONFIG??
    4. main(){
    5.     int i;
    6.     PORTA = 0x00;       // PORTA low
    7.     CMCON0 = 0x07;      // turn off comparators
    8.     ANSEL = 0x00;       // turn off ADC
    9.     TRISA = 0x00;       // RA1 as output
    10.         while(1 == 1){
    11.             if(RA1 == 0){
    12.                 RA1 = 1;
    13.             }
    14.             else{
    15.                 RA1 = 0;
    16.             }
    17.             for(i = 0; i <= 127; i++){
    18.                     __delay_ms(2);
    19.                     CLRWDT();
    20.             }
    21.         }
    22. }
    So basically where the '//CONFIG' is I have been trying a number of different ways to change the oscillator, wdt, MCLR and all that fun stuff. I've tried a number of different statements that I have seen in use here but I guess I'm just not totally sure on what format to use, since nothing seems to have an impact, or there are alot of errors during building.

    Thanks.

    edit:
    This is the most recent statement I have used
    __CONFIG(INTIO & WDTDIS & MCLRDIS & UNPROTECT)

    And I get about 30 errors/ warnings (every line+), and the code works flawlessly without.
     
    Last edited: Nov 17, 2009
  4. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,692
    901
    What processor are you using? Have you tried just setting the config in MPLAB? I use Assembly, where the config can be written individually or in hex, like this:

    Code ( (Unknown Language)):
    1.  
    2.     __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
    3.  
    4. ; __CONFIG 0FFA
    5.  

    John
     
  5. eng1

    New Member

    Oct 25, 2009
    13
    0
    Looks correct to me, except that I don't see the semicolon at the end of the line; that could be the cause of the exagerate number of errors ;)
    On a side note, if you disable the WatchDog Timer, you don't need to take care of it in your code.
    Hope this helps.
     
  6. SteveO

    Thread Starter Active Member

    May 15, 2008
    33
    0
    Haha amazing. Thanks alot, of course the semi-colon. Really appreciate the help. I was reading from the Hi-tech C PIC manual and was trying to follow the expression there, where there was no ;.

    And right, I understand now that I can remove the CLRWDT() command once it is disabled.

    Again, thanks for your time.
     
Loading...