Announcement

Collapse
No announcement yet.

Problems with setting fuses

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with setting fuses

    Hello everyone,

    I am new here and I have PBP3 Gold an MCSP. So far I really the compiler. One thing that is anoying me is I trying to set the fuses,but I keep getting errors. I went into the device info file for the pic I am using and copoied and pasted the example. I still am getting errors that say ()_ is a illegal character. I remove all the under scores at the beginning of the fuse and I still get errors. Can some one give me a working example of how I am to list the fuses? Thanks.

    Code:
    #Config
    
             INTRC_OSC_NOCLKOUT & WDT_OFF & LVP_OFF & CP_OFF & PWRTE_ON
      #ENDCONFIG
    Charlie
    Regards CharlieM

    Running PBP3 Gold
    MCSPX

  • #2
    Hi Charlie,

    It depends on the chip you are using, but here's an example for a 12F683.
    Note that __CONFIG has 2 underscores and the parameters each have 1 underscore
    Code:
    #CONFIG
      __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _PWRTE_ON & _CP_OFF & _CPD_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF
    #ENDCONFIG
    Here's one for a 16F887.
    It has 2 CONFIG words so you need to specify them by name.
    Note, __CONFIG has 2 underscores, _CONFIG1 has 1 underscore and the parameters each have 1 underscore.
    Code:
    #CONFIG
      __CONFIG _CONFIG1, _INTOSC & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _LVP_OFF  & _IESO_OFF & _FCMEN_OFF
      __CONFIG _CONFIG2, _BOR21V & _WRT_OFF
    #ENDCONFIG
    Or, you can be a little trickier and comment everything. This gives shorter lines too.
    Note, cfg1 must start in column 1, and __CONFIG must not start in column 1.
    Code:
    #CONFIG
    cfg1=       _INTOSC      ; Oscillator
    cfg1=cfg1&  _WDT_OFF     ; Watchdog Timer
    cfg1=cfg1&  _PWRTE_ON    ; Power-Up Timer
    cfg1=cfg1&  _MCLRE_OFF   ; Master Clear Reset
    cfg1=cfg1&  _CP_OFF      ; Code Protect
    cfg1=cfg1&  _CPD_OFF     ; EEPROM Data Protect
    cfg1=cfg1&  _BOR_OFF     ; Brown Out Reset
    cfg1=cfg1&  _LVP_OFF     ; Low Voltage Programming
    cfg1=cfg1&  _IESO_OFF    ; Internal External Switchover
    cfg1=cfg1&  _FCMEN_OFF   ; Fail-Safe Clock Monitor
      __CONFIG _CONFIG1, cfg1
    
    cfg2=       _BOR21V      ; Brown Out Reset Voltage
    cfg2=cfg2&  _WRT_OFF     ; Flash memory Write Protect
      __CONFIG _CONFIG2, cfg2
    
    #ENDCONFIG
    You can get even more "tricky" by using PBP3's Conditional Compiling.
    This example automatically selects the proper Oscillator setup for USB (48Mhz) with any supported crystal on the 18Fxx50 series chips. It even tells you if you have selected the wrong chip in the IDE.
    Code:
    DEFINE OSC 48
    #DEFINE CRYSTAL 12
    
    ;----[Hardware Configuration]-------------------------------------------------
    #if __PROCESSOR__ = "18F2450" OR __PROCESSOR__ = "18F2550" OR _
        __PROCESSOR__ = "18F4450" OR __PROCESSOR__ = "18F4550"
      #config        ; removes Default Configs
      #endconfig
      #ifndef CRYSTAL
        #error "#DEFINE CRYSTAL xx required for " + __PROCESSOR__
      #endif
      #if CRYSTAL = 4
        @FOSC = _FOSC_XTPLL_XT_1H
        @PDIV = _PLLDIV_1_1L
      #else
        @FOSC = _FOSC_HSPLL_HS_1H
        #if CRYSTAL = 8
          @PDIV = _PLLDIV_2_1L
        #else
          #if CRYSTAL = 12
            @PDIV = _PLLDIV_3_1L
          #else
            #if CRYSTAL = 16
              @PDIV = _PLLDIV_4_1L
            #else
              #if CRYSTAL = 20
                @PDIV = _PLLDIV_5_1L
              #else
                #if CRYSTAL = 24
                  @PDIV = _PLLDIV_6_1L
                #else
                  #error "Unsupported CRYSTAL frequency"
                #endif
              #endif
            #endif
          #endif
        #endif
      #endif
      ASM
        __CONFIG  _CONFIG1L, PDIV & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        __CONFIG  _CONFIG1H, FOSC & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG  _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
        __CONFIG  _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
        __CONFIG  _CONFIG3H, _PBADEN_OFF_3H
        __CONFIG  _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
      ENDASM
      ADCON1 = $0F    ; All Digital
    #else
      #error "Processor " + __PROCESSOR__ + " Not Supported with these CONFIGs"
    #endif
    Many of the newer 18F's cannot use the __CONFIG directive.
    You have to use the CONFIG (no underscore) directive instead and the syntax is very different.
    Here's an example for an 18F67J50.
    Code:
    #config
        CONFIG  FOSC = HSPLL        ; Oscillator
        CONFIG  PLLDIV = 5          ; for 20 mhz crystal
        CONFIG  CPUDIV = OSC1       ; DIVIDE BY 1 MODE
        CONFIG  XINST = OFF         ; Extended Instruction Set (Always OFF)
        CONFIG  STVREN = ON         ; Stack Over/Underflow
        CONFIG  WDTEN = OFF         ; Watchdog Timer
        CONFIG  CP0 = OFF           ; Code Protect
        CONFIG  IESO = OFF          ; Internal External Switchover
        CONFIG  FCMEN = OFF         ; Fail-Safe Clock Monitor
        CONFIG  CCP2MX = DEFAULT    ; CCP2 Multiplexer
        CONFIG  MSSPMSK = MSK5      ; MSSP Address Masking Mode
    #endconfig
    Hope that helps.
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

    Comment


    • #3
      Thanks Darrel. That clears things up.
      Regards CharlieM

      Running PBP3 Gold
      MCSPX

      Comment


      • #4
        OK maybe I am being thick headed so where is the best place to get the available fueses for the pic being used? for example if I am using a 16F877a where would I get the fuses in the syntax the PBP likes? I tried the device info file,but I get errors when I try to compile.
        Regards CharlieM

        Running PBP3 Gold
        MCSPX

        Comment


        • #5
          First, open the PIC16F877A.pbpinc file in the DEVICES folder and look at the __config statement in the #CONFIG block.
          That shows the syntax.

          Then open the PIC16F877A.info file in the DEVICE_REFERENCE folder.
          That will show the available options.
          PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
          Never download a PIC datasheet from anywhere but microchip.com

          Comment


          • #6
            OK Thanks Darrel. I think I have it now.
            Regards CharlieM

            Running PBP3 Gold
            MCSPX

            Comment

            Working...
            X