#config length ?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2004
    Posts
    64

    Default #config length ?

    Dear friends:

    In PBP3,all pics are assembled with MPLAB,
    EXAMPLE:

    For the PIC 16F886 I am using

    #CONFIG
    __config _CONFIG1,_INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_ON
    __config _CONFIG2, _BOR21V
    #ENDCONFIG
    It works OK,but the first line excceds the 80 chars for line.
    Can I separate the second part "_LVP_OFF & _CP_ON " maybe with
    another line as:
    __CONFIG _CONFIG1,_LVP_OFF & _CP_ON ?
    I tried that ,but it generates a compiler error.

    The new reference manual states the fuses separated for the PICS18...
    This works for the PIC16 too ?

    Thanks in advance...
    Ruben de la Pena Valdes.

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


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    I count 76, are you sure that's the error?
    -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!

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


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    You can use something like that
    Code:
    #CONFIG
    CFG1    = _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF 
    CFG11   = _LVP_OFF & _CP_ON
    
            __config _CONFIG1, CFG1 & CFG11
            __config _CONFIG2, _BOR21V
    #ENDCONFIG
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    cnc, it's not an error, it's just over the IDE gutter (which you can still move to whatever else but 80).
    Steve

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

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    I would like to know the same thing... That is, how can one break long "__CONFIG" lines into shorter lines?

    Below is an example of how to compile your program for two different PIC's, 16F1828 and 16F690. It works NOW... but getting the config statements right cost me a lot of time.

    Specifically the fact that "__CONFIG _CONFIG1," works for 16F1828 and "__CONFIG" (no comma) had to be used for the 16F690.

    Is the fact that some PIC's require a comma in the config line and some do not determined by MPLAB??

    Code:
    #IF __PROCESSOR__ = "16F1828"
        #CONFIG
               __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
               __CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_25 & _LVP_OFF
        #endconfig
        #else
           #IF __PROCESSOR__ = "16F690"
             #CONFIG
               __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _CPD_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF
             #endconfig
               #ELSE 
               #ERROR "Program does not support " + __PROCESSOR__
           #ENDIF
    #endif
    
    #msg "compiling for target " + __PROCESSOR__
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

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


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    If the chip only has one config word, you don't specify the word's name because it doesn't have one.
    For chips with more than one config word, you must specify the word with _CONFIG1 or _CONFIG2 etc.

    If you like commenting everthing really well, you can do the configs like this ...
    Code:
    #if __PROCESSOR__ = "16F1828"
        #config
    CFG =       _FOSC_INTOSC         ; Oscillator
    CFG=CFG&    _WDTE_ON             ; Watch Dog Timer 
    CFG=CFG&    _PWRTE_OFF           ; Power-on Timer
    CFG=CFG&    _MCLRE_OFF           ; Master Clear Reset
    CFG=CFG&    _CP_ON               ; Code Protect
    CFG=CFG&    _CPD_OFF             ; EEPROM Data Protect
    CFG=CFG&    _BOREN_OFF           ; Brown-out Detect
    CFG=CFG&    _CLKOUTEN_OFF        ; FOSC/4 Output
    CFG=CFG&    _IESO_OFF            ; Internal External Switchover
    CFG=CFG&    _FCMEN_OFF           ; Fail-Safe Clock Monitor
       __CONFIG _CONFIG1, CFG
     
    CFG =       _WRT_OFF             ; Flash table writes
    CFG=CFG&    _PLLEN_OFF           ; 4xPLL OSC multiplier
    CFG=CFG&    _STVREN_OFF          ; Stack Over/Underflow
    CFG=CFG&    _BORV_25             ; Brown-out voltage
    CFG=CFG&    _LVP_OFF             ; Low Voltage Programming
       __CONFIG _CONFIG2, CFG
        #endconfig
    #else
        #IF __PROCESSOR__ = "16F690"
        #config
    CFG =       _INTRC_OSC_NOCLKOUT  ; Oscillator
    CFG=CFG&    _WDT_ON              ; Watch Dog Timer
    CFG=CFG&    _PWRTE_OFF           ; Power-on Timer
    CFG=CFG&    _MCLRE_OFF           ; Master Clear Reset
    CFG=CFG&    _CP_ON               ; Code Protect
    CFG=CFG&    _CPD_OFF             ; EEPROM Data Protect
    CFG=CFG&    _BOD_OFF             ; Brown-out Detect
    CFG=CFG&    _IESO_OFF            ; Internal External Switchover
    CFG=CFG&    _FCMEN_OFF           ; Fail-Safe Clock Monitor
      __CONFIG  CFG
        #endconfig
        #else
            #error "Program does not support " + __PROCESSOR__
        #endif
    #endif
    #msg "compiling for target " + __PROCESSOR__
    DT

  7. #7
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    Hi:
    Thanks Steve, it works now !.
    Greetings...
    Ruben de la Pena Valdes.

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


    Did you find this post helpful? Yes | No

    Default Re: #config length ?

    Still doable the long way, still easy though
    Code:
           ASM                  
                              
           __CONFIG _CONFIG1, B'11111101010100'                     
                              ; 1------------- CP:    Code Protection off
                              ; -1------------ CPMX:  CCP1 on RB0 
                              ; --1----------- DEBUG: Disabled.  RB<7:6> are general purpose i/o
                              ; ---11--------- WRT:   Write Protection off
                              ; -----1-------- CPD:   Code Protection off
                              ; ------0------- LVP:   Disabled.  RB3 Is General I/O
                              ; -------1------ BOREN: Enable Brown Out Reset
                              ; --------0----- MCLRE: Disable MCLR, RA5 Is digital I/O
                              ; ----------0--- PWRTE: Enable Power-Up Timer
                              ; -----------1-- WDTEN: Enable Watch Dog Timer
                              ; ---------1--00 FOSC:  INTRC, NOCLKOUT 
    
           __CONFIG _CONFIG2, b'11111111111100'
                              ; xxxxxxxxxxxx-- unimplemented
                              ; ------------0- IESO: Disable Internal/External Swichover
                              ; -------------0 FCMEN: Disable Fail-Safe Clock Monitor
                              
           ENDASM
    Not too hot with that method, but neat
    Steve

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

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