Electronic – pic16f628a internal oscillator setup error undefined symbol “INTOSC”

oscillatorpic

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
    }
}

Best Answer

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.