config bits


Closed Thread
Results 1 to 6 of 6

Thread: config bits

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The .inc file Joe is referring to is located in the PBP directory - it's not the one in the MPASM directory. If you open it up you'll see something like this: (this is for another PIC though)
    Code:
            LIST
            LIST p = 18F4220, r = dec, w = -302, f = inhx32
            INCLUDE "P18F4220.INC"  ; MPASM  Header
            __CONFIG    _CONFIG1H, _XT_OSC_1H
            __CONFIG    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_ON_2L
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
            __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _CCP2MX_ON_3H
            __CONFIG    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    It's these __CONFIG lines you're supposed to comment out in order to have them in your program OR you can edit them to suit your need in the .inc file directly but make sure you back up the original.

    The file you're looking at (from the MPASM directory) is what defines names for the various CONFIG-settings (and everything else in the PIC) and it is what shows you WHICH cofig bits are available and in which CONFIG-word they are for that particular PIC.

    As you can see, the .inc file from the MPASM directory is included in the project BY the .inc file in the PBP-directory (the line INCLUDE "P18F4220.INC" ; MPASM Header. It does this in order to allow you to, in your program, use "names" like PORTD, TRISD, TMR0 instead of the actual memory adress for the particular register.

    Here's a part of the file you quoted earlier:
    Code:
    ;----- CONFIG2H Options --------------------------------------------------
    _WDTEN_OFF_2H EQU H'FE' ; WDT is controlled by SWDTEN bit of the WDTCON register
    _WDTEN_ON_2H EQU H'FF' ; WDT is always enabled. SWDTEN bit has no effect.
    
    _WDTPS_1_2H EQU H'E1' ; 1:1
    _WDTPS_2_2H EQU H'E3' ; 1:2
    _WDTPS_4_2H EQU H'E5' ; 1:4
    _WDTPS_8_2H EQU H'E7' ; 1:8
    This shows you the names for the "config options" available in the CONFIG2H word, so if you want to enable the Watchdog timer and set its prescaler to 1:4 you do:
    Code:
    @ __CONFIG _CONFIG2H, __WDTEN_ON2H & _WDTPS_4_2H
    Now, this IS a confusing subject and it comes up here a lot. I usually use a bootloader and seldom mess with the CONFIG fuses in the program so I'm not very confident with it either but I hope I haven't screwed up my explanation, if I have I'm sure someone will jump in and straighten it out.

    /Henrik.

  2. #2
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    thanks
    but please explaine the following.

    comment out.

    if i understand correctly!
    the inc file within the pbp, i copy and paste it in pbp program

    or do i have to change it within the inc file?

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Hi,
    If you want to set the CONFIG fuses in YOUR program they can't be set in the .inc file TOO, which they are by default. In order to be able to set them in YOUR you need to take them out of the .inc file.

    Commenting out means convert the lines to comments so that they don't get compiled/assembled. You do that with a semicolon, like this:
    Code:
            LIST
            LIST p = 18F4220, r = dec, w = -302, f = inhx32
            INCLUDE "P18F4220.INC"  ; MPASM  Header
    ;        __CONFIG    _CONFIG1H, _XT_OSC_1H
    ;        __CONFIG    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_ON_2L
    ;        __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    ;        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _CCP2MX_ON_3H
    ;        __CONFIG    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    See the semicolon at the beginning of the lines - this is effectively the same as deleting those lines from the file but "commenting them out" instead allows you to easily revert back if need be.

    Here's what happens. When you compile a program the compiler automatically adds the .inc file that is located in the PBP folder. The code in this file automatically adds the .inc file located in the MPASM folder.

Similar Threads

  1. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd November 2008, 00:51
  2. Error 0X0000008E when connecting a 18F2550 USB HID
    By FranciscoMartin in forum USB
    Replies: 8
    Last Post: - 16th October 2008, 18:20
  3. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 16:26
  4. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 04:56
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 15:31

Members who have read this thread : 0

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