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

    O.K. This is ask really often. Worth to be discussed NOW!

    What to do if i get "overwriting previous address content" error message?

    This error is return by PBP because your configuration fuse overwrite 'PBP default'. If you open with notepad, in PBP directory, the .INC file of your PIC, let's say 16F628, the file will look like this
    Code:
    ;**************************************************************
    ;*  16F628.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2002 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 09/27/02                                        *
    ;*  Version   : 2.43                                            *
    ;*  Notes     :                                                 *
    ;**************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M16F62x.INC'   ; PM header
            device  pic16F628, xt_osc, wdt_on, pwrt_on, mclr_on, lvp_off, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 16F628, r = dec, w = -302
            INCLUDE "P16F628.INC"   ; MPASM  Header
            __config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
            NOLIST
        endif
            LIST
    So if you try to define HS oscillator, wich is already define, you'll overwrite the previous content of the PBP setting.

    To fix it, just comment those lines :
    Code:
    ;device  pic16F628, xt_osc, wdt_on, pwrt_on, mclr_on, lvp_off, protect_off
    OR
    Code:
    ;__config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
    depending what you are using to compile your code, MPASM or PM.

    OR some will prefer to edit those line directly... as you wish...
    Where can i find the configuration fuse for my PIC ?

    All the configuration fuse are in the according .INC file located in the MPLAB directory. In MPLAB 7.01, the default directory, i suppose, is C:\Program Files\Microchip\MPASM Suite.

    If you open the appropriate .INC file, you will find all the configuration fuse for your PIC at the end of the file.

    looks like this for a 16F628...only the end
    Code:
    ;==========================================================================
    ;
    ;       Configuration Bits
    ;
    ;==========================================================================
    
    _BODEN_ON                    EQU     H'3FFF'
    _BODEN_OFF                   EQU     H'3FBF'
    _CP_ALL                      EQU     H'03FF'
    _CP_75                       EQU     H'17FF'
    _CP_50                       EQU     H'2BFF'
    _CP_OFF                      EQU     H'3FFF'
    _DATA_CP_ON                  EQU     H'3EFF'
    _DATA_CP_OFF                 EQU     H'3FFF'
    _PWRTE_OFF                   EQU     H'3FFF'
    _PWRTE_ON                    EQU     H'3FF7'
    _WDT_ON                      EQU     H'3FFF'
    _WDT_OFF                     EQU     H'3FFB'
    _LVP_ON                      EQU     H'3FFF'
    _LVP_OFF                     EQU     H'3F7F'
    _MCLRE_ON                    EQU     H'3FFF'
    _MCLRE_OFF                   EQU     H'3FDF'
    _ER_OSC_CLKOUT               EQU     H'3FFF'
    _ER_OSC_NOCLKOUT             EQU     H'3FFE'
    _INTRC_OSC_CLKOUT            EQU     H'3FFD'
    _INTRC_OSC_NOCLKOUT          EQU     H'3FFC'
    _EXTCLK_OSC                  EQU     H'3FEF'
    _LP_OSC                      EQU     H'3FEC'
    _XT_OSC                      EQU     H'3FED'
    _HS_OSC                      EQU     H'3FEE'
    
            LIST
    Last edited by mister_e; - 5th March 2005 at 19:04.
    Steve

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

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,Steve

    Thank you for the answer, I finally found what I was looking for : in the M16F84.inc,and others .inc all the values do not appear !!!
    So, I simply had to add them ...

    My question was more about how to have the Hex file written on the HDD ...
    as it appears in the program window and can be downloaded to the Pic.

    IF this stupid uncancellable error message was only a Warning things would be so simpler !!! ( errorlevel - ... etc )

    So, I ask it again : is there something reasonnably possible to memorize the content of the program window ??? ( yeah, write it on a paper .... Thanks !!! )

    Mhhh ... fore core calculation, have a look here :
    http://www.epcos.com/web/generator/W...locale=en.html

    read you soon
    Have a nice Sunday

    Alain

  3. #3
    RUBiksCUbe's Avatar
    RUBiksCUbe Guest


    Did you find this post helpful? Yes | No

    Talking

    Oh yeah! Got it working!! I needed to put in the PIC defines in the beginning. It was giving me those errors because I didn't need the line:

    @ INCLUDE "P18F252.INC" ; MPASM Header

    I'm not sure why I dont need it, but I think its because 18F252.INC has an identical line in it, so I was including it twice. Thanks soooo much!!!

  4. #4
    eoasap's Avatar
    eoasap Guest


    Did you find this post helpful? Yes | No

    Default

    Hi, i'm using the 18F452 chip so required to use MPASM compiler through Picbasic.
    if i try to set a fuse using ONLY (for example) the line below

    @ __config _LVP_OFF

    i get this error:
    x.asm 112: symbol not previously defined (_LVP_OFF)
    x.asm 112: argument out of range (not a valid config register address)



    if i put the following code:
    @ INCLUDE "P18F452.INC" ; MPASM Header
    @ __config _LVP_OFF

    i get errors like the following:
    '1042: duplicate label ("DDRA" or redefining symbol that cannot be redefined)
    1607: superseding current maximum RAM and RAM map
    120: symbol not previously defined (_LVP_OFF)
    etc..

    i've been trying for a while now with no luck setting the fuses. any ideas what i'm doing wrong?

    thanks!

  5. #5
    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 17:27.
    Steve

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

  6. #6
    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

  7. #7
    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 23:32.
    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, 17: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, 15:46
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  4. size of program vs mem on pic
    By PICMAN in forum General
    Replies: 1
    Last Post: - 1st March 2005, 18:23
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 16:45

Members who have read this thread : 5

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