18F Config fuses


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

    Default 18F Config fuses

    Hi Everyone

    I am migrating a project from a 16F877A to an 18F452 and need to set the 18F config fuses
    I'm using MCS/PBP2.46/Picbasic compiler
    I have all the @ DEVICE config fuses for 16F devices, but where can I get a list of the config fuses for the 18F452? Nothing in the PBP manual.
    Melanie's helpful post on setting config fuses says to go to the INC folder in the PBP folder, and your device should be listed there with the answers
    Trouble is, no 18F devices are listed in the INC file, only 10/12/14/16/17 series devices.

    Setting the fuses in the programmer every time I compile is a pain!!

    Any advice will be appreciated

    Angus Anderson

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Check the file P18F452.INC in the MPASM Suite folder. At the bottom is the configuration fuse settings.

    The are the ones that I am currently using. For more description of the function refer to the data sheet under the section "Special Feature of the CPU". There it list all the fuses and there functions.

    Code:
    ;************************ 18F452 Configuration Fuses ***************************
    
    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
    ; Oscillator Switchover Disabled
    ; Oscillator Type HS PLL    
     
    @ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
    ; Brown-Out Reset Enabled
    ; Power-Up Timer Enabled
    ; Brown-Out Reset Voltage 4.5V
    
    @ __CONFIG _CONFIG2H, _WDT_ON_2H 
    ; Watch Dog Timer Enabled
    
    @ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    ; Stack Over/Underflow Reset Enabled
    ; Low Voltage ICSP Programming Disabled
    ; Background Debugger Disabled
    
    ;*******************************************************************************

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


    Did you find this post helpful? Yes | No

    Default

    I'll also suggest you to read Melanie's thread again, at least from POST 1 to 5.
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thanks CCKid, and Steve for your replies.

    I do understand the way that 18F configs work (studied the datasheet for hours!), but my problem is to try and get the syntax for the PM assembler config statements for the 18F. All the very clear examples (thanks chaps) are examples using the syntax for the MPASM assembler. Are there a set of 18F config directives for the PM assembler (@ device blah blah)? What I am sensing here is that most of you 18F users are using MPASM and if so, I will have to migrate.

    Lets chuck a further thought into the pot. Is there a way in PBP that I can directly write to 18F config memory locations 30000 to 3000x the same way that I can write to EEPROM i.e without going to an assembler TBLREAD/WRITE routine to do it? That way would solve my problem instantly, 'cos I can just include it as a program statement or statements

    Thanks guys

    Angus Anderson

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I may be mistaken but I believe you have to use the MPASM assembler with the 18F series of chips. What is the problem with using MPASM? I just installed it and told MCSP to use it for my assembling and it works perfect.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    As CocaColaKid said... 18F's MUST use the MPASM Assembler.

    Here is an EXAMPLE (for PIC18F2420) of the instructions that can be included at the start of your PBP program...

    Code:
    	'
    	'	PIC Defines for PIC18F2420
    	'	==========================
    
    	@ __CONFIG    _CONFIG1H, _IESO_OFF_1H & _FCMEN_OFF_1H & _OSC_INTIO67_1H
    			' Oscillator Switch-over Disabled
    			' Fail-Safe clock Monitor Disabled
    			' _OSC_INTIO67_1H Set for Internal Oscillator RA6 & RA7 Enabled
    	@ __CONFIG    _CONFIG2L, _BOREN_ON_2L & _PWRT_ON_2L & _BORV_0_2L
    			' Brown-Out Reset Enabled
    			' Power-On Timer Enabled
    			' Brown-Out Trip set to 4.2v
            @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    			' WatchDog is ON
    			' Watchdog Postscaler set to 1:128
    	@ __CONFIG    _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTC_3H
    			' MCLR is OFF (internal)
    			' PortB 4:0 is digital on Reset
    			' CCP2 is Multiplexed with PortC.1
            @ __CONFIG    _CONFIG4L, _STVREN_ON_4L & _XINST_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    			' Stack Under/Overflow will Reset System
    			' Enhanced CPU Addressing Disabled
    			' Low-Voltage Programming is OFF
    			' DEBUG is Disabled
    	@ __CONFIG    _CONFIG5L, _CP1_ON_5L & _CP0_ON_5L
    			' All Code Protect
            @ __CONFIG    _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H
    			' EEPROM is Code Protected
    			' Boot Block code is Code Protected
    Here is an extract from the P18F2420.INC file in the MPLAB MPASM Suite subdirectory... note how (1) The ones needed have been copied from the INC file and inserted into the CONFIG statement.... and (2) for detailed explaination of each feature, refer to the DATASHEET - but I mustn't say that because I'll get flamed, so instead direct your queries to various members of the forum who'll read the Datasheet for you...

    Code:
    ;----- CONFIG1H Options --------------------------------------------------
    _OSC_LP_1H           EQU  H'F0'    ; LP oscillator
    _OSC_XT_1H           EQU  H'F1'    ; XT oscillator
    _OSC_HS_1H           EQU  H'F2'    ; HS oscillator
    _OSC_RC_1H           EQU  H'F3'    ; External RC oscillator, CLKO function on RA6
    _OSC_EC_1H           EQU  H'F4'    ; EC oscillator, CLKO function on RA6
    _OSC_ECIO6_1H        EQU  H'F5'    ; EC oscillator, port function on RA6
    _OSC_HSPLL_1H        EQU  H'F6'    ; HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
    _OSC_RCIO6_1H        EQU  H'F7'    ; External RC oscillator, port function on RA6
    _OSC_INTIO67_1H      EQU  H'F8'    ; Internal oscillator block, port function on RA6 and RA7
    _OSC_INTIO7_1H       EQU  H'F9'    ; Internal oscillator block, CLKO function on RA6, port function on RA7
    
    _FCMEN_OFF_1H        EQU  H'BF'    ; Fail-Safe Clock Monitor disabled
    _FCMEN_ON_1H         EQU  H'FF'    ; Fail-Safe Clock Monitor enabled
    
    _IESO_OFF_1H         EQU  H'7F'    ; Oscillator Switchover mode disabled
    _IESO_ON_1H          EQU  H'FF'    ; Oscillator Switchover mode enabled
    
    ;----- CONFIG2L Options --------------------------------------------------
    _PWRT_ON_2L          EQU  H'FE'    ; PWRT enabled
    _PWRT_OFF_2L         EQU  H'FF'    ; PWRT disabled
    
    _BOREN_OFF_2L        EQU  H'F9'    ; Brown-out Reset disabled in hardware and software
    _BOREN_ON_2L         EQU  H'FB'    ; Brown-out Reset enabled and controlled by software (SBOREN is enabled)
    _BOREN_NOSLP_2L      EQU  H'FD'    ; Brown-out Reset enabled in hardware only and disabled in Sleep mode (SBOREN is disabled)
    _BOREN_SBORDIS_2L    EQU  H'FF'    ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
    
    _BORV_0_2L           EQU  H'E7'    ; Maximum setting
    _BORV_1_2L           EQU  H'EF'    ; 
    _BORV_2_2L           EQU  H'F7'    ; 
    _BORV_3_2L           EQU  H'FF'    ; Minimum setting
    
    ;----- CONFIG2H Options --------------------------------------------------
    _WDT_OFF_2H          EQU  H'FE'    ; WDT disabled (control is placed on the SWDTEN bit)
    _WDT_ON_2H           EQU  H'FF'    ; WDT enabled
    
    _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
    _WDTPS_16_2H         EQU  H'E9'    ; 1:16
    _WDTPS_32_2H         EQU  H'EB'    ; 1:32
    _WDTPS_64_2H         EQU  H'ED'    ; 1:64
    _WDTPS_128_2H        EQU  H'EF'    ; 1:128
    _WDTPS_256_2H        EQU  H'F1'    ; 1:256
    _WDTPS_512_2H        EQU  H'F3'    ; 1:512
    _WDTPS_1024_2H       EQU  H'F5'    ; 1:1024
    _WDTPS_2048_2H       EQU  H'F7'    ; 1:2048
    _WDTPS_4096_2H       EQU  H'F9'    ; 1:4096
    _WDTPS_8192_2H       EQU  H'FB'    ; 1:8192
    _WDTPS_16384_2H      EQU  H'FD'    ; 1:16384
    _WDTPS_32768_2H      EQU  H'FF'    ; 1:32768
    
    ;----- CONFIG3H Options --------------------------------------------------
    etc etc etc
    You will need to modify the 18F2420.INC file located in your PBP directory to something like this... (remembering to backup the original)...
    Code:
    ;****************************************************************
    ;*  18F2420.INC                                                 *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2004 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 12/31/04                                        *
    ;*  Version   : 2.46                                            *
    ;*  Notes     : Butchered by Melanie                            *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F2420, r = dec, w = -311, f = inhx32
            INCLUDE "P18F2420.INC"   ; MPASM  Header
    
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	8
    This is because the MPASM Assembler cannot handle CONFIG conflicts....

    Finally, to make it all compile (and remembering to ensure you have a PATH embedded pointing to your MPASM directory), you can compile with a command line like...

    PBPW -p18F2420 MyProgram -ampasmwin -v

    Hey presto... it'll compile and embed all your selected CONFIG directives into the resultant HEX file (and as a bonus MPASM displays a lovely green progress bar that just makes you feel all warm and fuzzy inside).

    You may get some warning messages (they're just Warnings and NOT Errors) from MPASM that the CONFIG statements have been depricated, but a search on this forum will reveal how to suppress those.

  7. #7
    Join Date
    Feb 2005
    Posts
    67


    Did you find this post helpful? Yes | No

    Smile Rtfm

    Hi Guys, Hi Melanie.

    I had a problem with how to program or assemble the 18F4320, The forums kept saying, and very correctly, use MPASM.

    I wnt to MPSAM and tried to assemble but it wanted a .asm not .bas.

    Then at the end of this post, prior to mine it showed the / to use mpasm in the pbpw line.

    I havent tried it yey, but Im sure it will work.

    Less pulling out hair now I feel !!! Thanks.

    And most people will know what RTFM stands for, and yes, if I had done that, and
    if it could jump out bite, it would have !!!
    Pete

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Thanks Guys for all the responses and Melanies detailed explanation
    Well, by learning that 18F requires the MPASM assembler only, you totally solved my problem

    Viva la Picbasic Forum!

    Angus

  9. #9


    Did you find this post helpful? Yes | No

    Default

    You can also just use MCSP which passes all the necessary information to the assembler for you

  10. #10


    Did you find this post helpful? Yes | No

    Default

    I got the whole thing to compile guys, thanks

    Use:
    PBP 2.46
    MPLAB 7.30
    Win98SE to compile

    A few observations-

    1) MPASM told me when compiling that I had dual specifications for the config file. I did have config statements in the source file. By REM'ing the config statements in the PBP 18F452.INC file, it compiled fine with MPASM

    Why the dual sensing? Surely the assembler will check if there is a config statement in the source, and if not, use the .INC file to set a default? Why pick up both?

    2)What compiled with 7607 bytes on a 16F877A using the PM compiler actually compiles to 12477 bytes using the MPASM compiler. I can't believe that I have lost 1/2 of what I hoped to gain in code space by converting to an 18F device - that is, 4K. Is this normal?

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


    Did you find this post helpful? Yes | No

    Default

    tut tut...7607 WORDS with a 16F, 12477 BYTES for a 18F... still much compact in an 18F... no?
    Steve

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

  12. #12


    Did you find this post helpful? Yes | No

    Default

    Well, I learn every day. Thanks Mr_E

    You know, I'm a kind of mid-level programmer, I suppose. By that I mean that I know 16F stuff and PBP pretty well but have had a kind of a rocky ride moving up to 18F.

    There are a few things that illustrate:

    I had no idea that 18F only compiled with MPASM. Where do PBP tell us this? They don't

    *****************************************
    From Mr_E
    tut tut...7607 WORDS with a 16F, 12477 BYTES for a 18F... still much compact in an 18F... no?
    *****************************************

    I also had no idea that an 18F compiled file was expressed as bytes (18F) instead of words (16F). (And Melanie, I'll kill you if you tell me to look for this stuff in page xx sub xx sub xx of the documentation, because I cant find it

    I'm not wingeing. What I want to say is that there are a lot of people out there who need answers that are not in the manual, and thank goodness, the experts in this forum provide them. But boy, have I battled to find out what cooks with my 16F to 18F migration.

    So you guys who are so patient with seemingly stupid requests, bear with us please.
    We appreciate it more than you think

    I would not be able to conduct my small consultancy without your technical help

    Angus

  13. #13
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    And Melanie, I'll kill you if you tell me to look for this stuff in page xx sub xx sub xx of the documentation, because I cant find it
    *smiles*

    1. If you had attempted a compile with an 18F part using the standard (default) PM Assember, one of the first lines to hit your screen would have been...

    "Error: PM does not support this device. Use MPASM."

    This is (in case you missed it) a clue to get you on the right track...

    2. If you had ever compiled using MPASM, at the end of the listing (file.LST) it says BYTES for 18F series and WORDS for the 12F, 16F etc... The PICs DATASHEET (here we go I feel a fatwa coming on - btw, does anybody ever get a thin one?), anyway check the 18F452 Datasheet MEMORY ORGANISATION chapter and you discover...

    "The PIC18F252 and PIC18F452 each have 32 Kbytes of FLASH memory, while the PIC18F242 and PIC18F442 have 16 Kbytes of FLASH. This means that PIC18FX52 devices can store up to 16K of single word instructions, and PIC18FX42 devices can store up to 8K of single word instructions."

    Are we still friends Angus or is it Kevlar vest time?

    Anyway, digressing... it's time you thought about using the 4520 version rather than the plain 452. Heaps more versatile and CHEAPER too...

  14. #14


    Did you find this post helpful? Yes | No

    Default

    Hi Guys-

    Melanie, I'm afraid that I will always be a fatwa not a thinwa...., and kevlar not needed..
    I have been able to get PBP to compile with MPASM, thanks to your advice.
    I was caught, though, by the __CONFIG vs the CONFIG problem with MPASM.

    I still have a strange one.

    If I add config (not __config!) statements to my 18F source file, I get a list of very abstruse ASM compile errors with MPASM

    However, if I REM the source statements in my source file and cut and paste the same statements to the PBP 18F452.inc file, and comment out the __config statements, it assembles fine. I use PBP ver2.46.

    The bottom line is - why can't I use the same statements in my source file as in the .inc file?

    Any help welcomed


    Angus

  15. #15
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Angus Anderson, Have you commented them out in the include file? MPASM will bitch if it is being told to redifine of rewrite configuration locations.....

    Dave Purola,
    N8NTA

  16. #16


    Did you find this post helpful? Yes | No

    Default

    One other thing I noticed with 18F series is the stack won't POP out if you try to overflow it. It will just hang, lol. Found a gosub routine call that was not properly returned and kept crashing the application. The 16F just pushed the bug in the program out whenever it needed too, the 18F was a little more sticky about it though, lmao.

  17. #17


    Did you find this post helpful? Yes | No

    Default

    Hi Dave-

    Yes, I did comment it out in the include file when I specified the config fuses in the source file. It's just that I can get it to work with no config statements in the source file, and config statements specified in the include file, but NOT the other way around. Statement syntax is identical. This is a funny one.

    CCkid, there is an 18F config statement that allows resetting of a stack overflow. I enabled it

    regards

    Angus

  18. #18
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Angus Anderson, Could you please send the statements for the configurations you are trying to set? I'm sure it will shed some light on the problem.

    Dave Purola,
    N8NTA

  19. #19


    Did you find this post helpful? Yes | No

    Default

    Hi Dave- As you requested, here are the 2 files:



    This is the source file config statements (at present commented out)
    '--------------------------- Set Processor options. THIS IS MPASM -----------------------
    'ASM
    ' CONFIG OSCS=OFF, OSC=HS
    ' ; Oscillator switchover disabled, HS Osc enabled
    ' CONFIG BOR=ON, PWRT=ON, BORV=27
    ' ; BOR on, BOR acts at 2.7v
    ' CONFIG WDT=ON, WDTPS=128
    ' ; WDT off
    ' CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
    ' ; Stack over/underflow reset enabled
    ' ; LVP disabled
    ' ; Background debugger disabled
    'endasm

    This is the 18f452.inc file which, as mentioned, works

    ;************************************************* ***************
    ;* 18F452.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 01/27/04 *
    ;* Version : 2.45 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    "Error: PM does not support this device. Use MPASM."
    NOLIST
    else
    LIST
    LIST p = 18F452, r = dec, w = -311, f = inhx32
    INCLUDE "P18F452.INC" ; MPASM Header
    ;__CONFIG _CONFIG1H, _OSCS_OFF_1H & _XT_OSC_1H
    ;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
    ;__CONFIG _CONFIG4L, _LVP_OFF_4L
    CONFIG OSCS=OFF, OSC=HS
    CONFIG BOR=ON, PWRT=ON, BORV=27
    CONFIG WDT=ON, WDTPS=128
    CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
    NOLIST
    endif
    LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 8


    Any insight into the problem would be a help.
    BTW, PBPv2.46

    regards

    Angus

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


    Did you find this post helpful? Yes | No

    Default

    The new 18F config directive without the double underscore only works if you use it in the .inc file. They will not work when inserted directly in your code.

    If you comment out 18F config settings in the default PBP .inc file, then insert them directly in your code, you'll have to use the older __config directive.

    Newer versions of PBP include files now have the w = -230 option to suppress the deprecated warning message MPASM spits out when it sees the older __config directive, but it still doesn't allow inserting the new directives inline.
    Regards,

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

  21. #21


    Did you find this post helpful? Yes | No

    Default

    Hey Bruce-

    Wow! Thanks for solving the problem. Reliable as ever!

    Just wish that it was easier to find documented answers to problems such as this.

    Regards

    Angus Anderson

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