Today 03:53
Forum: USB
Starter: towlerg
Views: 12
Replies: 0
Today 03:19
Forum: USB Module
Starter: MTH
Views: 93
Replies: 10
Yesterday 14:32
Forum: Wish List / Product Feedback
Starter: Latex
Views: 20
Replies: 0
+ Reply to Thread
Results 1 to 6 of 6

Thread: Help setting up 18f4331 to run at 40 Mhz129 days old

  1. #1
    Junior Member Hornett's Avatar
    Join Date
    Apr 2015
    Posts
    22
    Thumbs Up
    Received: 3
    Given: 0
    Total Downloaded
    8.98 MB

    0 Not allowed!

    Default Help setting up 18f4331 to run at 40 Mhz

    Think I am missing something obvious, I want to run my 18f4331 at 40MHz, I have a 10MHz crystal and now trying to set the config1H register Fosc<0 to 3 to 0110 to set HS oscillator, PLL enable (clock frequency = 4x F0sc1)

    I can see from the 18f4331 inc file the options below but cannot work out the syntax
    ;----- CONFIG1H Options --------------------------------------------------
    _OSC_LP_1H EQU H'F0' ; LP
    _OSC_XT_1H EQU H'F1' ; XT
    _OSC_HS_1H EQU H'F2' ; HS
    _OSC_RC2_1H EQU H'F3' ; External RC, RA6 is CLKOUT
    _OSC_EC_1H EQU H'F4' ; EC, RA6 is CLKOUT
    _OSC_ECIO_1H EQU H'F5' ; EC, RA6 is I/O
    _OSC_HSPLL_1H EQU H'F6' ; HS-PLL Enabled
    _OSC_RCIO_1H EQU H'F7' ; External RC, RA6 is I/O
    _OSC_IRCIO_1H EQU H'F8' ; Internal RC, RA6 & RA7 are I/O
    _OSC_IRC_1H EQU H'F9' ; Internal RC, RA6 is CLKOUT, RA7 is I/O
    _OSC_RC1_1H EQU H'FB' ; External RC, RA6 is CLKOUT
    _OSC_RC_1H EQU H'FF' ; External RC, RA6 is CLKOUT

    I have tried the two methods given in "crystals, PLL's & Proton" given in he beginners section but no luck. What should I put between

    Config_Start
    ?
    Config_End

    I have tried:-
    osc_hspll_1h
    config1h_osc_hspll_1h
    config1h_osc_hspll_1h = 1
    CONFIG1H = %00000110
    FOSC = HSPLL_HS ;HS oscillator selected, PLL enabled (HSPLL)
    but all give me a config directive error on compile.

    Please help

    Ian






  2. #2
    Administrator John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,793
    Thumbs Up
    Received: 69
    Given: 25
    Total Downloaded
    617.39 MB

    0 Not allowed!

    Default Re: Help setting up 18f4331 to run at 40 Mhz

    Hello Hornet,
    For a good start look in the forum for Third party developments/Fuse configurator. John Barratt's program is excellent. Most of us use it as it overcomes a lot of the fuse confusion. It is a Plugin.
    This will get you started. I have no experience with the 18f4331 so can't directly help.
    John

  3. #3
    Junior Member Hornett's Avatar
    Join Date
    Apr 2015
    Posts
    22
    Thumbs Up
    Received: 3
    Given: 0
    Total Downloaded
    8.98 MB

    0 Not allowed!

    Default Re: Help setting up 18f4331 to run at 40 Mhz

    Thanks I give it a try!

  4. #4
    Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    356
    Thumbs Up
    Received: 17
    Given: 2
    Total Downloaded
    721.28 MB

    0 Not allowed!

    Default Re: Help setting up 18f4331 to run at 40 Mhz

    First, as John said, use the Fuse configurator as it can save a lot of trouble especially when microchip decide to retrospectively chance the fuse names resulting in a mismatch between the fuse what compiler expects (using the configurator assembler output get around that).

    The Fuse configurators output with the Osc set to HSPLL and the Low voltage programming mode off (best if not required) is...
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings

    Device = 18F4331

    Config_Start
    OSC = HSPLL ;HS oscillator, PLL enabled (clock frequency = 4 x FOSC1)
    FCMEN = ON ;Fail-Safe Clock Monitor enabled
    IESO = ON ;Internal External Switchover mode enabled
    PWRTEN = OFF ;PWRT disabled
    BOREN = ON ;Brown-out Reset enabled
    BORV = 20 ;Reserved
    WDTEN = ON ;WDT enabled
    WDPS = 32768 ;1:32768
    WINEN = OFF ;WDT window disabled
    PWMPIN = OFF ;PWM outputs disabled upon Reset (default)
    LPOL = HIGH ;PWM0, 2, 4 and 6 are active-high
    HPOL = HIGH ;PWM1, 3, 5 and 7 are active-high
    T1OSCMX = ON ;Low-power Timer1 operation when microcontroller is in Sleep mode
    FLTAMX = RC1 ;FLTA input is multiplexed with RC1
    SSPMX = RC7 ;SCK/SCL clocks and SDA/SDI data are multiplexed with RC5 and RC4, respectively. SDO output is multiplexed with RC7.
    PWM4MX = RB5 ;PWM4 output is multiplexed with RB5
    EXCLKMX = RC3 ;TMR0/T5CKI external clock input is multiplexed with RC3
    MCLRE = ON ;Enabled
    STVREN = ON ;Stack full/underflow will cause Reset
    LVP = OFF ;Low-voltage ICSP disabled
    DEBUG = OFF ;Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
    CP0 = OFF ;Block 0 (000200-000FFFh) not code-protected
    CP1 = OFF ;Block 1 (001000-001FFF) not code-protected
    CPB = OFF ;Boot Block (000000-0001FFh) not code-protected
    CPD = OFF ;Data EEPROM not code-protected
    WRT0 = OFF ;Block 0 (000200-000FFFh) not write-protected
    WRT1 = OFF ;Block 1 (001000-001FFF) not write-protected
    WRTC = OFF ;Configuration registers (300000-3000FFh) not write-protected
    WRTB = OFF ;Boot Block (000000-0001FFh) not write-protected
    WRTD = OFF ;Data EEPROM not write-protected
    EBTR0 = OFF ;Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
    EBTR1 = OFF ;Block 1 (001000-001FFF) not protected from table reads executed in other blocks
    EBTRB = OFF ;Boot Block (000000-0001FFh) not protected from table reads executed in other blocks
    Config_End

    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------


    Personally I prefer the Format 2 Assembler output as it avoids the fuse name compatibility issues and saves space for device that have a lot of fuses which would be...
    ;-------------------------------------------------------------------------------
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings

    Device = 18F4331

    Declare Reminders Off
    @ CONFIG_REQ = 0 ; Override Compiler's configuration settings
    asm-
    __Config Config1H, 0xC6 ;OSC_HSPLL & FCMEN_ON & IESO_ON
    __Config Config2L, 0x0F ;PWRTEN_OFF & BOREN_ON & BORV_20
    __Config Config2H, 0x3F ;WDTEN_ON & WDPS_32768 & WINEN_OFF
    __Config Config3L, 0x3C ;PWMPIN_OFF & LPOL_HIGH & HPOL_HIGH & T1OSCMX_ON
    __Config Config3H, 0x9D ;FLTAMX_RC1 & SSPMX_RC7 & PWM4MX_RB5 & EXCLKMX_RC3 & MCLRE_ON
    __Config Config4L, 0x81 ;STVREN_ON & LVP_OFF & DEBUG_OFF
    __Config Config5L, 0x03 ;CP0_OFF & CP1_OFF
    __Config Config5H, 0xC0 ;CPB_OFF & CPD_OFF
    __Config Config6L, 0x03 ;WRT0_OFF & WRT1_OFF
    __Config Config6H, 0xE0 ;WRTC_OFF & WRTB_OFF & WRTD_OFF
    __Config Config7L, 0x03 ;EBTR0_OFF & EBTR1_OFF
    __Config Config7H, 0x40 ;EBTRB_OFF
    endasm-
    Declare Reminders On

    ;**** End of Fuse Configurator Settings ****
    ;-------------------------------------------------------------------------------

    And remember to get the XTAL = and PLL_REQ = combination correct when using PPL's as explained in the crystals, PLL's & Proton Wiki article.

  5. #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,098
    Thumbs Up
    Received: 44
    Given: 83
    Total Downloaded
    1.35 GB

    0 Not allowed!

    Default Re: Help setting up 18f4331 to run at 40 Mhz

    Yes it is shorter but a bugger to change "on the fly", once I have the fuses sorted (with fuse Configurator obviously) I move them to an include file or to the end of the main file.
    George

  6. #6
    Junior Member Hornett's Avatar
    Join Date
    Apr 2015
    Posts
    22
    Thumbs Up
    Received: 3
    Given: 0
    Total Downloaded
    8.98 MB

    0 Not allowed!

    Default Re: Help setting up 18f4331 to run at 40 Mhz

    Thanks for the help the fuse configurator is a great piece of kit, and thanks for the advice on fuses. All looks to be configured OK now and compiling no problem. Need to get my head round the next issue now .
    Thanks again
    Ian

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

     

Similar Threads

  1. 18f4331 QEI function for two encoders
    By Hornett in forum Absolute Beginners Section
    Replies: 0
    Last Post: 28th November 2016, 06:04
  2. 18F4331 Bootloader
    By pic-ignorant in forum The Lounge
    Replies: 13
    Last Post: 21st September 2013, 23:53
  3. Replies: 2
    Last Post: 26th April 2013, 16:31
  4. Proton IDE Compiler wont run/Crashes when IDE is run on my Windows 7
    By XMAXY123 in forum Proton Plus Compiler v3
    Replies: 11
    Last Post: 5th February 2012, 09:06
  5. MCloader, from 10 MHz to 4 MHz
    By MadAl in forum Mecanique - IDE
    Replies: 7
    Last Post: 28th December 2008, 16:25

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts