DEFINE OSC Compiler Error Message


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2010
    Posts
    50

    Default DEFINE OSC Compiler Error Message

    Hi,
    I am experiencing this problem with both PIC18F4520 and PICF4515. I am using the following code to define the osc frequency. Each time I try to compile I get a compiler error of
    Error[176] c:\pbp\...... 204: CONFIG Directive Error: (setting "32" not found for the processor 18F4515)

    code:

    @ CONFIG OSC = INTIO67 ;config for internal osc
    @ CONFIG PBADEN=OFF ;turn of port b analog inputs
    @ CONFIG MCLRE=ON ;activate master clear
    @ CONFIG WDT = OFF ;turn off watchdog timer
    @ CONFIG STVREN = OFF ;turn off reset on overflow/underflow
    @ CONFIG LVP = OFF ;turn off low voltage programming

    Include "modedefs.bas"
    define OSC 32
    OSCCON = %01110000 'set internal oscillator to 8 mhz and select it as system clock
    OSCTUNE= %11000000 'turn on pll frequency is now 32
    INTCON = %00000000 'turn off all interupt functions
    ADCON0 = %00000000 'turn off adcs set to digital i/o
    ADCON1 = %00001111 'turn off adcs set to digital i/o
    TRISA = %00000000 'set port A to all outputs
    TRISB = %00000000 'set port B to all outputs
    TRISC = %10001011 'set port C
    TRISD = %00000000 'set port D to all outputs
    TRISE = %00000000 'set port E to all outputs
    PORTA = %00000000 'set all outputs on port a to 0
    PORTB = %00010000 'set outputs on port b to 0
    PORTD = %00000000 'set all outputs on port d to 0
    PORTE = %00000000 'set all outputs on port e to 0
    WDTCON = %00000000 'turn off wdt

    Any help would be greatly appreciated. Thanks.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    On these chips, I think you will have to put your configs back into the .inc file, rather than in your code. Basically, there is an OSC in the microchip pxxxx.inc file, that does not get allong with the pbp OSC definition.

    For instance, on the PIC18F4520, the oscillator settings are:
    ; Oscillator Selection bits:
    ; OSC = LP LP oscillator
    ; OSC = XT XT oscillator
    ; OSC = HS HS oscillator
    ; OSC = RC External RC oscillator, CLKO function on RA6
    ; OSC = EC EC oscillator, CLKO function on RA6
    ; OSC = ECIO6 EC oscillator, port function on RA6
    ; OSC = HSPLL HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
    ; OSC = RCIO6 External RC oscillator, port function on RA6
    ; OSC = INTIO67 Internal oscillator block, port function on RA6 and RA7
    ; OSC = INTIO7 Internal oscillator block, CLKO function on RA6, port function on RA7

    On a PIC18F4550 they are:
    ; Oscillator Selection bits:
    ; FOSC = XT_XT XT oscillator, XT used by USB
    ; FOSC = XTPLL_XT XT oscillator, PLL enabled, XT used by USB
    ; FOSC = ECIO_EC External clock, port function on RA6, EC used by USB
    ; FOSC = EC_EC External clock, CLKOUT on RA6, EC used by USB
    ; FOSC = ECPLLIO_EC External clock, PLL enabled, port function on RA6, EC used by USB
    ; FOSC = ECPLL_EC External clock, PLL enabled, CLKOUT on RA6, EC used by USB
    ; FOSC = INTOSCIO_EC Internal oscillator, port function on RA6, EC used by USB
    ; FOSC = INTOSC_EC Internal oscillator, CLKOUT on RA6, EC used by USB
    ; FOSC = INTOSC_XT Internal oscillator, XT used by USB
    ; FOSC = INTOSC_HS Internal oscillator, HS used by USB
    ; FOSC = HS HS oscillator, HS used by USB
    ; FOSC = HSPLL_HS HS oscillator, PLL enabled, HS used by USB

    At some point in time Microchip switched FOSC to OSC, and when you declare your Configs in your code, it brings up this conflict for some of these newer chips.
    For a wacky work around, and better explanation, I had the same problem with another chip.
    http://www.picbasic.co.uk/forum/show...0824#post90824

    Simple and cleaner solution is to declare these back in the PBP .inc files.

  3. #3
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    Thanks for the reply. Does seem wacky! So what I need to do is:

    1. Make a backup copy of your PBPPIC18.LIB.
    2. Now use an editor to find & replace all instances of OSC with XTAL.
    3. Save the .LIB file, and compile with DEFINE XTAL 48, and the new config directives in your code.

    So for my need for 32 mHz, I should change my define statement to:
    DEFINE XTAL 32 instead of DEFINE OSC 32

    Do I also need to remove the config stuff and put it back in the .inc file?
    Thanks, again.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    I would skip the wacky work around, and do the easy way. A lot safer that way. That would be to remove the configs from your code, and put them back into where MeLabs had them, in the PBP .inc file for that chip. In your case the 18F4520.INC file. You should still be able to define the oscillator in your code. Don't ask me why.

  5. #5
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    Just move the config settings? I'll try but I thought I have already tried that. I gave up and decided to just run the chip faster and compensate otherwise. Once again, thank for the help
    !

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    You know, I think I did not understand what Bruce was trying to explain to me in the old thread. Because this does compile for the PIC18F4520
    Code:
    asm
        __CONFIG    _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
        __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    endasm
     
    ;@ CONFIG OSC = INTIO67 ;config for internal osc
    ;@ CONFIG PBADEN=OFF ;turn of port b analog inputs
    ;@ CONFIG MCLRE=ON ;activate master clear
    ;@ CONFIG WDT = OFF ;turn off watchdog timer
    ;@ CONFIG STVREN = OFF ;turn off reset on overflow/underflow
    ;@ CONFIG LVP = OFF ;turn off low voltage programming
    Include "modedefs.bas"
    define OSC 32
    OSCCON = %01110000 'set internal oscillator to 8 mhz and select it as system clock
    OSCTUNE= %11000000 'turn on pll frequency is now 32
    INTCON = %00000000 'turn off all interupt functions
    ADCON0 = %00000000 'turn off adcs set to digital i/o 
    ADCON1 = %00001111 'turn off adcs set to digital i/o
    TRISA = %00000000 'set port A to all outputs
    TRISB = %00000000 'set port B to all outputs
    TRISC = %10001011 'set port C 
    TRISD = %00000000 'set port D to all outputs
    TRISE = %00000000 'set port E to all outputs
    PORTA = %00000000 'set all outputs on port a to 0
    PORTB = %00010000 'set outputs on port b to 0
    PORTD = %00000000 'set all outputs on port d to 0
    PORTE = %00000000 'set all outputs on port e to 0
    WDTCON = %00000000 'turn off wdt
    So, I guess if you convert your configs to the style above you will be ok?

  7. #7
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    Yep, It will now compile with your suggestion! Thanks, I guess I'll just start using that method for all the config settings for the 18 series chips.

    Thanks, Again.

  8. #8
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: DEFINE OSC Compiler Error Message

    Quote Originally Posted by cc1984 View Post
    Yep, It will now compile with your suggestion! Thanks, I guess I'll just start using that method for all the config settings for the 18 series chips.

    Thanks, Again.

    Update: I changed the the configuration settings to use the ASM....END ASM and the program compiled with no errors. When I installed the programmed chip in the circuit, it did absolutely nothing. After scratching my head a while, I tried the "Wacky Work-around" discussed above and went back to my orginal configuration setting method (@ CONFIG....). The work-around works! Not sure I even want to try and figure this one out.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts