# pic16f628a internal oscillator setup error undefined symbol "INTOSC"

I want to set internal oscillator for pic16f628a, according to datasheet page 96, I have to set FOSC_INTOSC, but I get this error main.c:11: error: undefined symbol "FOSC_INTOSC"

if I set the other option FOSC_HS or FOSC_LP or FOSC_XT it works fine (no error)

but it's not working with FOSC_RC and FOSC_INTOSC .it's not because for FOSC_RC and FOSC_INTOSC, there is two possible value for both of them (page 96 datasheet)?????

code :

#include<htc.h>
#include <pic.h>
#include <pic16f628a.h>
// Config word
__CONFIG(FOSC_INTOSC & WDTE_OFF & PWRTE_ON & CP_OFF);

// Define LED pin
#define LED  RA0

// Define CPU Frequency
// This must be defined, if __delay_ms() or
// __delay_us() functions are used in the code
#define OSC 4
// Main function
void main()
{
TRISA0 = 1;                // Make RA0 pin output
TRISB = 1;
LED    = 0;                // Make RA0 low
while(1)
{
LED = 0;               // LED off
LED = 1;               // LED on
}
}

• Try FOSC_RC and se how it goes, I think some compilers use that instead of FOSC_INTOSC. Jul 16, 2014 at 11:04
• same error for FOSC_RC, I think because for FOSC_RC and FOSC_INTOSC there is two possible value for both of them (page 96 datasheet) Jul 16, 2014 at 11:06

Find the appropriate #include file that your compiler is using for the particular chip you are using and look at it. That's the only way to be 100% sure what is (supposed to be) going on.

For example, here is a snippet from a HTC include file pic16f628a.h:

// INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OS/CLKIN
#define FOSC_INTOSCCLK       0xFFFD
// INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
#define FOSC_INTOSCIO        0xFFFC
// EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN


The constant names are sometimes changed by the compiler supplier, and you may even find errors in the files, especially for very new chips.

• yes it works, thanks a lot, specialty for this advice :) Jul 16, 2014 at 11:21
• I succeed to set internal oscillator as you said, but sill nothing work on my previous question electronics.stackexchange.com/questions/121311/… , I just mad it like shown in the scheme, RA1 cant blink led, and RB5 RB6 RB7 even that they are set input, they turn on the led. Jul 16, 2014 at 12:09
• Did you follow my comment and set CMCON to 0x07?? This is not optional. Jul 16, 2014 at 12:10
• now when I set CMCON = 0x07; the RB5 RB6 RB7 stop turning on the led but RA1 still not working. one answer told me You must put a pull-up resistor to VDD on the MCLR pin, but even like that it's not working Jul 16, 2014 at 12:22
• You should get it to work on simulation (MPSIM) before burning it to the chip. Save yourself a lot of frustration. Jul 16, 2014 at 12:24