Presetting Configuration Fuses (PIC Defines) into your Program


+ Reply to Thread
Results 1 to 40 of 83

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The 18F serie work different from the other. In the MPASM directory open the according .INC file. Look at the end you'll discover how to use the Config directive.

    Free example here...
    Code:
    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
        ' Oscillator switch OFF
        ' Use HS oscillator (20MHZ here)
        '
    @ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
        ' Brown out reset ON @ 4.5Volts
        ' Power-up timer ON
        '
    @ __CONFIG _CONFIG2H, _WDT_ON_2H 
        ' Watch dog timer ON
        '
    @ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
        ' Stack over/underflow ON
        ' Low Voltage programming OFF
        ' Background debugger OFF
    Last edited by mister_e; - 29th October 2005 at 16:27.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    eoasap's Avatar
    eoasap Guest


    Did you find this post helpful? Yes | No

    Default

    Steve,

    Once again you are my savior
    Thanks alot for always helping me and guiding me in the right direction. your advice worked perfectly and i got the overwrite error which i see from your other post how to handle that.

    Thanks so much

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Warning[230] __CONFIG has been deprecated for PIC18 devices.

    If you are using any PIC18 serie, you will have this warning one day or another. Our friends from Microchip decide to change the way to define the config fuses when using the latest MPASM version 5.00.

    The solution is still located at the same place... at the end of the 18XXXX.INC file located in the MPASM folder.
    Quote Originally Posted by Snip of MPASM 18F452.INC

    ; IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
    ; superseded by the CONFIG directive. The following settings
    ; are available for this device.
    ;
    ; Oscillator Selection:
    ; OSC = LP LP
    ; OSC = XT XT
    ; OSC = HS HS
    ; OSC = RC RC
    ; OSC = EC EC-OSC2 as Clock Out
    ; OSC = ECIO EC-OSC2 as RA6
    ; OSC = HSPLL HS-PLL Enabled
    ; OSC = RCIO RC-OSC2 as RA6
    SO now the new method to set the config fuse on the PIC18 serie is...
    Code:
    @ CONFIG OSCS=OFF, OSC=HS
        ' Oscillator switch OFF
        ' Use HS oscillator (20MHZ here)
        '
    @ CONFIG BOR=ON, PWRT=ON, BORV=45
        ' Brown out reset ON @ 4.5Volts
        ' Power-up timer ON
        '
    @ CONFIG WDT=ON
        ' Watch dog timer ON
        '
    @ CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
        ' Stack over/underflow ON
        ' Low Voltage programming OFF
        ' Background debugger OFF
    Or if you prefer...
    Code:
    ASM
        CONFIG OSCS=OFF  ; Oscillator switch OFF
        CONFIG OSC=HS    ; Use HS oscillator (20MHZ here)
        CONFIG BOR=ON    ; Brown out reset ON 
        CONFIG BORV=45   ; Brown out detect voltage=4.5 Volt
        CONFIG PWRT=ON   ; Power-up timer ON      
        CONFIG WDT=ON    ; Watch dog timer ON
        CONFIG STVR=ON   ; Stack over/underflow ON
        CONFIG LVP=OFF   ; Low Voltage programming OFF
        CONFIG DEBUG=OFF ; Background debugger OFF
        ENDASM
    Don't forget to comment the default PBP config fuses...
    Last edited by mister_e; - 29th October 2005 at 22:32.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Nope can't get it going !!

    I've used
    Code:
    @ CONFIG FOSC = HS
    but it returns the error

    __CONFIG directives cannot be used with CONFIG directives

    I've even tried
    Code:
    @ CONFIG _CONFIG1H, _FOSC_HS_1H
    which returns the same error as above and also,
    Code:
    @ __CONFIG _CONFIG1H, _FOSC_HS_1H
    which returns two errors stating:
    Overwriting previous address contents (0000)
    Overwriting previous address contents (0001)

    Any ideas?

  5. #5
    eoasap's Avatar
    eoasap Guest


    Did you find this post helpful? Yes | No

    Default

    tissy, i just got the same thing you did. That's too bad because Steve's code looks so neat and orderly i personally would rather not use all the underscores and such.

  6. #6
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Right, i think i've figured this out.

    You need to find the 18F2550.INC (or whatever device you are using) in the PicBasic Pro installation directory.

    When you open that file it should look something like this:
    Code:
    ;****************************************************************
    ;*  18F2550.INC                                                 *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2004 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 12/31/04                                        *
    ;*  Version   : 2.46                                            *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F2550, r = dec, w = -311, f = inhx32
            INCLUDE "P18F2550.INC"	; MPASM  Header
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HS_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	32
    This is effectivly where you modify the fuses. The fuse definitions are contained within the P18F2550.INC as contained within your MPASMWIN directory.

    *** Note: My advice would be to back any files up before any modifications ***

    Hope this clears things up, it worked for me in the end. Now all the fuses are set without the need for modification each time.

    Steve

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Just to make things clear for everybody. My solution work!!! As i said in my previous post don't forget to comment the PBP default fuse wich are located in the PBP folder in the according .INC file as Tissy found. So after the modification, Tissy's .INC file will looks like
    Code:
    ;****************************************************************
    ;*  18F2550.INC                                                 *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2004 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 12/31/04                                        *
    ;*  Version   : 2.46                                            *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F2550, r = dec, w = -311, f = inhx32
            INCLUDE "P18F2550.INC"	; MPASM  Header
            ;__CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            ;__CONFIG    _CONFIG1H, _FOSC_HS_1H
            ;__CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
            ;__CONFIG    _CONFIG3H, _PBADEN_OFF_3H
            ;__CONFIG    _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	32
    If you don't comment the default fuses... you'll always have this Warning message + another like overwriting previous content..

    Also be sure you have the latest MPASM version. 5.00 as now.

    About now?
    Last edited by mister_e; - 30th October 2005 at 01:50.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. pic program crashing
    By comwarrior in forum General
    Replies: 5
    Last Post: - 8th July 2009, 16:33
  2. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. size of program vs mem on pic
    By PICMAN in forum General
    Replies: 1
    Last Post: - 1st March 2005, 17:23
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

Members who have read this thread : 3

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