Internal OSC, how to?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73

    Talking Internal OSC, how to?

    Hello again!

    I hope everybody had a good time during the holidays and also that you are having a good start on this New Year! :-)

    Today I have fiddled with some code and I run into a problem. I get an “Error [118] Overwriting previous address content (2007)” when compiling. If I omit the first line “@ __CONFIG _INTOSC_OSC_NOCLKOUT” there are no errors!
    I use MCS+ ,PBP and MPASM, the target is a 16F628A. According to the list of fuses in the *.INC file the alternatives are:

    _RC_OSC_CLKOUT
    _RC_OSC_NOCLKOUT
    _ER_OSC_CLKOUT
    _ER_OSC_NOCLKOUT
    _INTOSC_OSC_CLKOUT
    _INTOSC_OSC_NOCLKOUT
    _INTRC_OSC_CLKOUT
    _INTRC_OSC_NOCLKOUT

    What I like to do is have the 16F628A run @ 4 MHz internally and be able to compile it without errors.
    How do I make sure the clock setting in my code overrides the setting in the *.INC file?

    Here is the code:


    @ __CONFIG _INTOSC_OSC_NOCLKOUT

    Cnt VAR BYTE 'Declare Cnt as a byte

    TRISB = 0 ' Set PORTB pins as outputs

    AGAIN:
    FOR Cnt = 1 TO 3
    PORTB.0 = 1 ' Turn ON LED
    PAUSE 250 ' Wait 250ms
    PORTB.0 = 0 ' Turn OFF LED
    PAUSE 250 ' Wait 250ms
    NEXT Cnt

    PAUSE 2000 ' Wait 2 seconds

    GOTO AGAIN ' Repeat

    END ' End of program



    Thanks for being here!
    All the Best!

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi PICante.

    Have a Great 2008.

    Presetting Configuration Fuses (PIC Defines) into your Program
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    <br>
    DT

  3. #3
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Cool

    Hi Darrel!

    You Too!

    Thanks, but this link is where I got the line which got me in trouble in the first place :-) “@ __config _INTRC_OSC_NOCLKOUT” and even after I have changed it (after reading the datasheet about the differences between 628 and 628A) to “@ __CONFIG _INTOSC_OSC_NOCLKOUT”!

    Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    MPASM does not like multiple config declarations. Either comment out the defaults in the device header file, or change them in the header file & save it. You can't have the config directive in both the default header file and your code.
    Regards,

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

  5. #5
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Red face

    Hi Bruce,

    Are you saying that the error I got is generated by MPSAM and not PBP?
    In which order do the fuses in the 1. code, 2. *.INC file and the 3.programmer settings supersede each other? If I do not want to let the PBP automatically include the include file; where do I select this? If I remove it (the INC file) from the folder I get an error.
    Anyway, which is the correct fuse for internal 4 MHz; there are a few to choose from?

    Many questions, I am sorry!

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sorry, I should have been more specific.

    This post is in the thread I mentioned before.

    What to do if i get "overwriting previous address content" error message?
    http://www.picbasic.co.uk/forum/showthread.php?p=6775
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Yes this error is generated by MPASM. A list of MPASM assembler error codes can be found
    in the MPASM help file.

    You can't stop PBP from including device specific .INC files. You just need to learn how to
    use/modify them for your own needs.

    The error is due to the __config directive being seen in two places. 1 in the 16F628A.INC file,
    and 1 in your code.

    If you prefer to insert config options in your code, and use the MPASM assembler, then just
    comment out the __config line in the include file.

    If you insert config options in your code, and you're using the PM assembler, you don't need
    to comment out config options. The PM assembler will use whatever config options you have
    in your code & ignore the default config options in the 16F628A.INC file. MPASM will throw
    the error.

    From the 16F628A.INC file in your PBP install directory:
    Code:
            NOLIST
        ifdef PM_USED
            LIST
            include 'M16F62xA.INC'  ; PM header
            device  pic16F628A, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 16F628A, r = dec, w = -302
            INCLUDE "P16F628A.INC"  ; MPASM  Header
            ; __config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
            NOLIST
        endif
            LIST
    PBP automatically includes 16F628A.INC when you compile for this target.

    If the PM assembler is used ifdef PM_USED = true, and the M16F62xA.INC file is also
    included.

    If MPASM is used, then the P16F628A.INC file located in your MPLAB install directory is used.

    A list of all config options available for this PIC can be found in these secondary include files
    that 16F628A.INC points to.

    M16F62xA.INC if PM is used or P16F628A.INC if MPASM is used.

    _INTOSC_OSC_NOCLKOUT is the correct option for using the internal osc, but MPASM will
    complain if it sees the __config directive twice.

    So;
    1. Modify the config options in the PBP 16F628A.INC file.

    or;
    2. Comment the __config line out in this file, and drop them in your code.

    If you read through both threads Darrel linked to above, it should be easy to understand.
    Regards,

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

Similar Threads

  1. Internal vs. external osc for comms
    By mtripoli in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2010, 14:58
  2. 16F88 bootlader with Internal OSC
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 2nd August 2009, 10:15
  3. 18F4520 and internal osc & PLL
    By pwhitt in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th September 2008, 06:38
  4. Internal Osc help
    By BobK in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th January 2007, 20:50
  5. 12f675 internal osc question.....
    By Gabe@SPdFtsh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2004, 06:33

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