CONFIG Statement

Thread Starter

SteveO

Joined May 15, 2008
33
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.
 

Thread Starter

SteveO

Joined May 15, 2008
33
Sounds fair. lol. So I've just recently started playing with PIC's and have created a simple blinking LED program.
Rich (BB code):
#include <htc.h>
#define _XTAL_FREQ 4000000
//CONFIG??
main(){
	int i;
	PORTA = 0x00;		// PORTA low
	CMCON0 = 0x07;		// turn off comparators
	ANSEL = 0x00;		// turn off ADC
	TRISA = 0x00;		// RA1 as output
		while(1 == 1){
			if(RA1 == 0){
				RA1 = 1;
			}
			else{
				RA1 = 0;
			}
			for(i = 0; i <= 127; i++){
					__delay_ms(2);
					CLRWDT();
			}
		}
}
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:

jpanhalt

Joined Jan 18, 2008
11,087
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:

Rich (BB code):
	__CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC

; __CONFIG 0FFA

John
 

eng1

Joined Oct 25, 2009
13
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.
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.
 

Thread Starter

SteveO

Joined May 15, 2008
33
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.
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.
 
Top