Continue to Site

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.

  • 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.

CONFIG Statement

Status
Not open for further replies.

Dalaran

New Member
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.
 
WANTED: Craystal Ball

I do not use that compiler but unless you show us what you tried and what the errors were how are to to figure out what is wrong.

EDIT: Have you ever wished you could edit the title ? crystal

3v0
 
Last edited:
Fair enough ;).
This is my first successful code of a blinking LED, that is successful without the CONFIG statement. With it I get 30+ errors saying ';' expected, conflicting delcarations, etc.

Code:
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(INTIO & WTDDIS & MCLRDIS & UNPROTECT)
void main(void){
	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();
			}
		}
}

Thanks.
 
Last edited:
And the micro is...?
 
IF your not sure what config items there are look at the .lst file and you will find them in there.

Heres a list from 16f506


;_CP_OFF 00000FFF
;_CP_ON 00000FEF

;_EC_OSC 00000FFB
;_ExtRC_OSC_CLKOUTEN 00000FFF
;_ExtRC_OSC_RB4EN 00000FFE
;_HS_OSC 00000FFA
;_IntRC_OSC_CLKOUTEN 00000FFD
;_IntRC_OSC_RB4EN 00000FFC
;_LP_OSC 00000FF8

;_IOSCFS_OFF 00000FBF ;4mhz
;_IOSCFS_ON 00000FFF ;8mhz

;_MCLRE_OFF 00000FDF
;_MCLRE_ON 00000FFF

;_WDT_OFF 00000FF7
;_WDT_ON 00000FFF

__CONFIG _CP_OFF & _IntRC_OSC_RB4EN & _MCLRE_OFF & _WDT_OFF & _IOSCFS_OFF
 
Thanks for the help. Silly me, missing the semi-colon after the CONFIG statement leading to a mass amount of errors.

Thanks for your time people.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top