Another 2.60 worry


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216

    Default Another 2.60 worry

    Hi everyone, me again with another question concerning PBP 2.60

    2.60 Doesn't seem to like the following config stuff

    @ DEVICE pic16F886, HS_OSC ' System Clock Options
    @ DEVICE pic16F886, WDT_OFF ' Watchdog Timer
    @ DEVICE pic16F886, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F886, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F886, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F886, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F886, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F886, WRT_OFF ' Flash Memory Word Enable

    I have read through the Melabs blurb on config (Specifying configuration bit settings in PICBASIC PRO™ programs.)
    but can't get my head around the waffle.
    It's obviously written by geeks for other geeks to understand.
    Not being a geek I just can't understand any of it.

    So can anyone translate the above listing into a 2.60 config statement.

    I don't necessarily want to know what it all means, I just want a statement that works and that I can use over and over.
    I generally use the same Pic type for most things so a standard version of the above would be great.
    _CONFIG_ SOMETHING OR OTHER

    Thanks again,
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Hi,
    There IS a standard, basic, working most of the time configuration fuse setting already setup for each and every chip that the compiler supports. You don't have to set them in your code if the default is OK.

    If you wan't to see how they "work" and what they are simply open the .inc file for the specific target you're compiling for, it's located in the root of the PBP folder. For the 16F886 the fileneme is 16F866.INC and looks like this:
    Code:
            NOLIST
        ifdef PM_USED
            LIST
            include 'M16F88x.INC' ; PM header
            device  pic16F886, intrc_osc_noclkout, wdt_on, mclr_on, lvp_off, protect_off
            XALL
            NOLIST
    
        else
    
            LIST
            LIST p = 16F886, r = dec, w = -302
            INCLUDE "P16F886.INC" ; MPASM  Header
            __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
            NOLIST
        endif
            LIST
    Now, the @ DEVICE statement is used when you're using PM as the assembler and the __CONFIG (note two underscores) is used when you're using MPASM as the assembler. If you're Win7 you can't use PM which means you're using MPASM which means @ DEVICE is the wrong "command".

    In order to find out the "names" of the various fuses go to your MPASM folder and open the P16F886.INC file, at the end of that file you'll find this:
    Code:
    ;==========================================================================
    ;
    ;       Configuration Bits
    ;
    ;==========================================================================
    _CONFIG1                     EQU     H'2007'
    _CONFIG2                     EQU     H'2008'
    ;----- Configuration Word1 ------------------------------------------------
    _DEBUG_ON                    EQU     H'1FFF'
    _DEBUG_OFF                   EQU     H'3FFF'
    _LVP_ON        EQU     H'3FFF'
    _LVP_OFF       EQU     H'2FFF'
    _FCMEN_ON                    EQU     H'3FFF'
    _FCMEN_OFF                   EQU     H'37FF'
    _IESO_ON                     EQU     H'3FFF'
    _IESO_OFF                    EQU     H'3BFF'
    _BOR_ON                      EQU     H'3FFF'
    _BOR_NSLEEP                  EQU     H'3EFF'
    _BOR_SBODEN                  EQU     H'3DFF'
    _BOR_OFF                     EQU     H'3CFF'
    _CPD_ON                      EQU     H'3F7F'
    _CPD_OFF                     EQU     H'3FFF'
    _CP_ON                       EQU     H'3FBF'
    _CP_OFF                      EQU     H'3FFF'
    _MCLRE_ON                    EQU     H'3FFF'
    _MCLRE_OFF                   EQU     H'3FDF'
    _PWRTE_ON                    EQU     H'3FEF'
    _PWRTE_OFF                   EQU     H'3FFF'
    _WDT_ON                      EQU     H'3FFF'
    _WDT_OFF                     EQU     H'3FF7'
    _LP_OSC                      EQU     H'3FF8'
    _XT_OSC                      EQU     H'3FF9'
    _HS_OSC                      EQU     H'3FFA'
    _EC_OSC                      EQU     H'3FFB'
    _INTRC_OSC_NOCLKOUT          EQU     H'3FFC'
    _INTRC_OSC_CLKOUT            EQU     H'3FFD'
    _EXTRC_OSC_NOCLKOUT          EQU     H'3FFE'
    _EXTRC_OSC_CLKOUT            EQU     H'3FFF'
    _INTOSCIO                    EQU     H'3FFC'
    _INTOSC                      EQU     H'3FFD'
    _EXTRCIO                     EQU     H'3FFE'
    _EXTRC                       EQU     H'3FFF'
    ;----- Configuration Word2 ------------------------------------------------
    _WRT_OFF                     EQU     H'3FFF'    ; No prog memmory write protection
    _WRT_256                     EQU     H'3DFF'    ; First 256 prog memmory write protected
    _WRT_1FOURTH                 EQU     H'3BFF'    ; First quarter prog memmory write protected
    _WRT_HALF                    EQU     H'39FF'    ; First half memmory write protected
    _BOR21V             EQU     H'3EFF'
    _BOR40V             EQU     H'3FFF'
    So, to change the CONFIG fuses you have two options:
    1) Edit the 16F866.INC file in the PBP folder to have the CONFIG you want/need. Do make a backup of the original file first.
    2) Comment out the CONFIG from the 16F866.INC file and instead put them in your code.

    /Henrik.

  3. #3
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Rightio, I opened the M16f88x.inc file in the PBP directory.
    That first example you gave does not exist anywhere in the file??
    This is getting all too hard..I'm gunno go play soliraire.

    I do understand that I can edit the first example you gave and make it into a new default that suits me.
    But, as I said, it ain't in there.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Hi Muddy,

    Not those Mxxx inc files, these 16f886.inc files . Check here: C:\PBP\

    Name:  incs.PNG
Views: 1037
Size:  74.7 KB
    Last edited by ScaleRobotics; - 27th July 2011 at 17:47.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Ah, come on now Peter...
    If you wan't to see how they "work" and what they are simply open the .inc file for the specific target you're compiling for, it's located in the root of the PBP folder. For the 16F886 the fileneme is 16F866.INC and looks like this:
    Why did you go open the M16F88x.inc ? (I don't even have that file on my system.)

    It's not THAT hard...but you have to actually read ;-)

  6. #6
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Aah, there it is. I didn't look through the whole directory, did I?
    So If I change
    __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
    NOLIST
    endif

    to

    __config _CONFIG1, _XT_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    NOLIST
    endif

    that should then make the default suit my preference? And I shouldn't need to do a config with any new programs, unless I want or need to change them?

    Thanks Man.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  7. #7
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    after a bit more experimentation....should be

    __config _CONFIG1, _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
    NOLIST
    endif
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Yep, looks good to me. As you can see, the different configuration settings for the oscillator (and everything else) are at the bottom of the P16F886.inc file (the one in the MPASM folder):
    Code:
    _LP_OSC                      EQU     H'3FF8'
    _XT_OSC                      EQU     H'3FF9'
    _HS_OSC                      EQU     H'3FFA'
    _EC_OSC                      EQU     H'3FFB'
    _INTRC_OSC_NOCLKOUT          EQU     H'3FFC'
    _INTRC_OSC_CLKOUT            EQU     H'3FFD'
    _EXTRC_OSC_NOCLKOUT          EQU     H'3FFE'
    _EXTRC_OSC_CLKOUT            EQU     H'3FFF'
    _INTOSCIO                    EQU     H'3FFC'
    _INTOSC                      EQU     H'3FFD'
    _EXTRCIO                     EQU     H'3FFE'
    _EXTRC                       EQU     H'3FFF'
    On the 16F886 there are two CONFIG words (on other chips there are more) so if you need to change something that resides in another CONFIG word you have to add a second line, like
    Code:
       __config _CONFIG2, WRT_HALF & _BOR21V
    Then you have your defaults and it is what will be included in every program you compile for that particular target, no need to have them in your code if you don't want to.

    /Henrik.

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Just throwing in my 10 cents here. Instead of changing the defaults in the PBP file, just make a seperate file with the configs you want. It can be a 1 line file with just
    Code:
    __config yada yada yada
    then "INCLUDE" the file in your programs. There are 2 reasons I suggest this. First is if you change the PBP file, then upgrade later, all your changes are lost. Second It is a simple matter to change your include file for different setups like now you want to use internal osc and so forth. Also it is much easier to understand for YOU in a year or 2 what the configs were doing without having to track down the .inc and read it.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  10. #10
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Quote Originally Posted by cncmachineguy View Post
    Just throwing in my 10 cents here. Instead of changing the defaults in the PBP file, just make a seperate file with the configs you want. It can be a 1 line file with just
    Code:
    __config yada yada yada
    then "INCLUDE" the file in your programs. There are 2 reasons I suggest this. First is if you change the PBP file, then upgrade later, all your changes are lost. Second It is a simple matter to change your include file for different setups like now you want to use internal osc and so forth. Also it is much easier to understand for YOU in a year or 2 what the configs were doing without having to track down the .inc and read it.
    Yeah, I probably will do that as soon as I work out the exact syntax etc. However the change to the inc file was a nice quick fixaround which works fine for now.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  11. #11
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,523


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    It's a good suggestion, just remember that you still have to edit the stock .INC file, commenting out the default config that's there.

  12. #12
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Bert, your idea of putting CONFIG statement in an include file is a great one that I want to implement in all of my codes. However, I tried it in one of my working application codes and the code stopped working afterwards. In hopes you can tell me why here is what I did:
    1. I created a new .inc file by copying and pasting the following statements into a new code file and saving it as a .inc file in the PBP folder where all of my codes are in a subfolder to the PBP folder.
    INCLUDE "18F2550_4550_CONFIGS.inc" ' Setup CONFIGS for MCU
    ;--- if you un-comment these, you must comment the ones in the .inc file--
    ;ASM ; 18F2550/4550, 8mhz crystal
    ;__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
    ;__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    ;__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
    ;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    ;__CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
    ;__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ;ENDASM

    2. I then replaced the CONFIG statements in my application code with the follwoing statement in which I commented out all of the original CONFIG statements:
    Include "18F2550_4550_CONFIGS.inc"
    ;--- if you un-comment these, you must comment the ones in the .inc file--
    ;ASM ; 18F2550/4550, 8mhz crystal
    ; __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
    ; __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
    ; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
    ; __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    ; __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
    ; __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    ;ENDASM

    3. The modified application code compiles and assembles OK and appears to run, but it no longer works correctly and I can't see why.

    4. If I comment out the new .inc statement and uncomment the _CONFIG statements it works OK again.

    Can you tell me what I am doing wrong?
    Thanks, John Ellis
    Last edited by jellis00; - 7th August 2011 at 22:56.

  13. #13
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    I assume they are not commented in the include file? I usually give the file a PBP extension, but I doubt that is it.Can you attach the .lst file created when you use the include?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  14. #14
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Just my thoughts . . . change the file extension to .bas and make it the first line of code . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  15. #15
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,625


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    I just override settings at the top of my programs.

    Code:
    ' PicBasic Pro program
    ' Michelle Science Project
    ' Game Show Buttons, version 1, April 2011
    
    ASM
    @ DEVICE PIC16F877, HS_OSC, WDT_OFF, PWRT_ON, BOD_ON, LVP_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF, PROTECT_OFF
    ENDASM
    
    DEFINE OSC 20       ' 15-33pF (22pF used)
    
    yada yada yada
    I could be using the default values; I never bothered to check.

    But as someone said, I don't loose settings with future upgrades. Or worse, have the default settings changed and pull what little hair I have left trying to find what is wrong in my code.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  16. #16
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Quote Originally Posted by cncmachineguy View Post
    I assume they are not commented in the include file? I usually give the file a PBP extension, but I doubt that is it.Can you attach the .lst file created when you use the include?
    I found what apparently was causing the problem, but don't quite understand why. I changed the file extension to .pbp and had it in a 2nd level folder below my PBP folder while my application code resides in a 3rd level folder. IT was my understanding that as long as an include file was in a folder at a higher level than the code that was using it, that the INCLUDE statement would find it. However, unless I placed the include file in the same folder as my application code or moved the file to the PBP folder my application code wouldn't work. As long as it was in the 2nd level folder my application code wouldn't work.

    Can anyone tell me how this works?

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


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Just specify the path in your include line then. I do it all the time.

    I have a root folder named PBP_PROG and some subfolders. One subfolder by application and a couple of other for various include type (DevBoards headers, LCD/GLCD drivers/wrapper, etc etc etc)
    C:\PBP_Prog
    C:\PBP_Prog\DemoXyz
    C:\PBP_Prog\Nokia3310

    Assuming I'm working on a prgram located in DemoXyz folder, If I want to use the Nokia3310 related include I just need to use the following line
    INCLUDE "..\Nokia3310\GLCD_NOKIA.PBP"

    the file extension do not make any difference, it could be .inc, pbp, bas, bak.. whatever.

    For Win7/Vista, you may have a error message if the path+filename exceed 32 characters (or so)

    All config fuses are in my code, never elsewhere/ I comment out the one in the PBP folder all the tie. Fortunately now with PBP3 we no longer need to do so. This reminds me I need to upgrade today... where<s my proof of purchase now... arg... I know I have it somewhere. Back in 1999/2000
    Last edited by mister_e; - 8th August 2011 at 19:29.
    Steve

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

  18. #18
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    Quote Originally Posted by mister_e View Post

    the file extension do not make any difference, it could be .inc, pbp, bas, bak.. whatever.
    :
    As I continue to learn . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default Re: Another 2.60 worry

    figure an include to be nothing more than a text substitution... on a single line.
    Steve

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

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