Definitive MPLAB Config Examples


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default Definitive MPLAB Config Examples

    Please forgive me if I am going over old ground but I am unfamiliar with the forum and find the search difficult to use. (doubtless my own fault)

    I am currently moving yet another project from 16F to 18F and am encountering difficulties with MPASM's requirements for code defined device configuration. On previous ocassions I chickened out and edited the .inc file instead of sorting the problem.

    This time, I wan't to do it properly.

    Page 14 of the MPASM PIC18F2450 processor include file makes an "IMPORTANT" statement.

    "For the PIC18 devices, the __CONFIG directive has been superceded by the CONFIG directive". It then lists the new parameter options for each configuration function but there is no syntax example.

    I assume, in PBP, the config line should begin withe the '@' sign followed by a space and the word CONFIG in upper case followed by the various parameters, again in upper case, with their included spaces (I've tried omitting included spaces) and where there is more than one parameter they should be immediately separated by commas without additional spaces. Please correct me if I am wrong.

    As a lengthy string is likely to be generated, I assume a line continuation character is included in the scheme, can someone tell me what it is?

    An old post I have from Bruce tech@rentron shows how to do it but omits the starting '@ space', I assume that he intended that for PBP that's to be included. Bruce's post also included the translation of '_OSCS_OFF_1H' to 'OSCS_OFF'. Could someone please explain what 'OSCS_OFF' means in either dialect. I don't see it noted in the available settings for the 18F4620.

    Here is the CONFIG line so far:

    @ CONFIG OSC = HS,WDT = ON,PWRT = ON,BOREN = OFF,LVP = OFF

    When I try the above, MPASM gives me the red band of pain and declares an error:

    '__CONFIG directives cannot be used with CONFIG directives'

    Any help greatly appreciated...

    Brian Walsh.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    This isn't the "end-all-be-all" of figuring out how to set up the CONFIG fuses, but it's probably the best thing out there so far:
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    As a lengthy string is likely to be generated, I assume a line continuation character is included in the scheme, can someone tell me what it is?
    It's the underscore _ . The reference is a bit hidden in the manual, but it's there.

    Could someone please explain what 'OSCS_OFF' means in either dialect. I don't see it noted in the available settings for the 18F4620.
    It's not a valid setting for the '4620. You probably want IESO instead.
    If you open up the P18F4620.INC file in \Microchip\MPASM Suite, you'll see all of the available config fuse options at the bottom of the file along with a fairly decent explanation of what they are. Of course, a better explanation is in the actual datasheet itself.
    I usually take that whole chunk of information for whatever PIC I'm using, copy/paste it over to the 18F4620.INC file in the PBP directory and comment it out, then re-write the config register settings as I want them.

    This is another recent post and self-fix somebody else had:
    http://www.picbasic.co.uk/forum/showthread.php?t=9093

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Brian,

    I wouldn't be really concerned about using the new 18F config directive unless just want
    to modifiy your existing PBP header files to be compatible with the latest changes.

    Note: This may change by next week the way Microchip works..;o}

    If you're referring to this thread: http://www.picbasic.co.uk/forum/show...3087#post13087
    it should be OSCS=OFF VS OSCS_OFF. The new config directive does not support the
    underscore character.

    As to whether or not this particular config fuse option is even available for the PIC in
    question, follow Skis' advice and look in the default Microchip device header file. This
    shows every config option available for the target PIC. Of course, you'll also want to
    take a peek at the datasheet for the PIC in question. They don't all have the same
    config fuse options.

    If your case, for the 18F4620, it does not appear that the controller has the option for
    OSCS=OFF (which would be the Osc Switch Enable) as, say, you would have for an 18F452.

    The Microchip device .INC header files give a very descriptive list of what each config fuse
    option does. The data sheet goes into much greater detail.

    Here's a short clip from the P18F452.INC file;

    ; Osc. Switch Enable:
    ; OSCS = ON Enabled
    ; OSCS = OFF Disabled
    ;
    ; Power-up Timer:
    ; PWRT = ON Enabled
    ; PWRT = OFF Disabled
    ;
    ; Brown-out Reset:
    ; BOR = OFF Disabled
    ; BOR = ON Enabled

    These are config fuse options you can use with the new config directive for the 18F452.

    Now look in the P18F4620.INC file in your MPLAB installation directory for a list of config fuse
    options that are available for this target.

    NOTE: You cannot (at least for now) use the new config directives directly in your PBP code.

    PBP will not allow these to be inserted directly in your code. You'll need to modify the default
    18F4620.INC file in your PBP directory.

    That's why you don't see the @ symbol before the config fuse directive in my example at
    the link above.This is only required when you insert the (old config directives) directly into
    your PBP code (and you have the others commented out) as shown below. It's not required
    when you do this in the PBP .INC file.

    Here's an example of my own modified 18F2431.INC file in my PBP directory.
    Code:
    LIST
            LIST p = 18F2431, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "C:\Program Files\Microchip\MPASM Suite\P18F2431.INC"  ; MPASM  Header
    	CONFIG OSC=XT,FCMEN=OFF,IESO=OFF,PWRTEN=ON,BOREN=ON,BORV=27
    	CONFIG WDTEN=OFF,WINEN=OFF,WDPS=128,T1OSCMX=OFF,MCLRE=OFF
    	CONFIG LVP=OFF,STVREN=OFF
            ;__CONFIG    _CONFIG1H, _OSC_IRCIO_1H ; _OSC_XT_1H
            ;__CONFIG    _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
            ;__CONFIG    _CONFIG4L, _LVP_OFF_4L
            NOLIST
    I use an old Windows ME OS, so I have to point directly to my MPASM suite directory, and
    I've changed to the new config directive. I can't directly insert the new config directive in
    my PBP code. It just doesn't work.

    I can, however, alter my default PBP 18F2431.INC file to use these.

    Yeah, I know, it seems confusing, but it's worth the extra effort to learn this.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4


    Did you find this post helpful? Yes | No

    Default Definitive MPLAB Config Examples

    Thanks folks.

    My understanding is as follows:

    1. PBP does not directly support the new CONFIG directive.

    2. The old style @ __CONFIG still works within the PBP code.

    3. The line continuation character for in line assembly is the same as for PBP i.e. "_".

    4. I can edit the .inc file and use the new CONFIG and its new, clearer parameters there.

    Maybe I didn't chicken out after all! If editing the .inc is good enough for Bruce, it's good enough for me.

    Just noticed that the HS oscillator option for an 18F452 is _HS_OSC_1H and for an 18F4620 it has been handily transposed to _OSC_HS_1H. What fun what fun!

    Thanks again,

    Brian Walsh.

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. Error 0X0000008E when connecting a 18F2550 USB HID
    By FranciscoMartin in forum USB
    Replies: 8
    Last Post: - 16th October 2008, 17:20
  4. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 15:26
  5. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 03:56

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