18F Config fuses


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1


    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.

  2. #2
    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.

  3. #3
    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

  4. #4


    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

  5. #5


    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

  6. #6


    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?

  7. #7
    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.

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 : 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