Config & Oscon settings 16F1825


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1

    Default Config & Oscon settings 16F1825

    I'm migrating from my trusty 12F683 to a 16F1825 and am confused by the config and oscon settings. I'm using PBP3 of course

    With 12F683 I have the following.

    Code:
    #config
     __config _FCMEN_ON & _IESO_ON & _BOD_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTOSCIO
    #ENDCONFIG
    
    OSCCON = 01110101  'Sets internal osc to 8 Mhz (Default) and stable
    I just want to make that work with the 16F1825 but using the 16mhz int oscilator. I don't need anything fancy. I appreciate the 16F1825 has two config words.

    I was thinking something like

    Code:
    #config
     __CONFIG _CONFIG1, _FCMEN_ON & _IESO_ON & _FOSC_INTOSC & _WDTE_SWDTEN & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
     __CONFIG _CONFIG2, _LVP_OFF
    #ENDCONFIG
    Does the config need to be in CAPITALS? Does the above look comparable to what I have for the 12F683.

    With the Oscon reg I'm very confused and am reading the datasheet. I just want it to run at 16mhz on the into osc but all the other settings are making my brainhurt!

    I'm also confused about the relationship between the config words and the oscon reg PLLEN etc etc ARRGHHH!!

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    I use its larger sibling (16f1828), and have it set something like this for 16Mhz

    Code:
    @ __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF & _LVP_OFF
    @ __CONFIG _CONFIG2, _LVP_OFF
    DEFINE  OSC 16
    Osccon = 111010   'sets the internal oscillator to 16Mhz
    Re the PLL...it confused me too, I haven't got access to the config settings I used (I certainly had it working at 32Mhz at one stage) , but the jists seems to be if you haven't got any refereence to PLLEN_ON in you config, then bit 7 of the Osccon register turns on the PLL

    Edit: I don't know what's going on thereshould be a percentage sign and a leading 0 at the front of that Osccon entry...they are both disappearing when I click 'post reply'
    Last edited by HankMcSpank; - 16th September 2011 at 21:19.

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


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    Try this
    Code:
            #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _IESO_OFF & _FOSC_INTOSC & _PLLEN_OFF & _WDTE_SWDTEN & _MCLRE_OFF & _CP_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _LVP_OFF
            #ENDCONFIG
    
            OSCCON = 1000
                    ' x------- SPLLEN: don't care when _PLLEN_OFF in config fuse
                    ' -1111--- Internal clock = 16MHz
                    ' -----x-- Unimplemented
                    ' ------00 System Clock Source = Determined by Config Word
            
            DEFINE OSC 16 ' Tell PBP we use a 16MHz Clock
    MPASM is case sensitive, IF the config are not in capital you'll receive some Symbol not previously defined error message.

    EDIT: Yup, there should indeed have a percent sign ... Looks like the new vBulletin have new "Features"

    Above the above OSCCON should be
    OSCCON = % 01111000
    without the space between percent signe and the first 0
    Last edited by mister_e; - 16th September 2011 at 21:29.
    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 & Oscon settings 16F1825

    Out to do more test in the test area...
    Last edited by mister_e; - 16th September 2011 at 21:37.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    last test, sorry ....

    Code:
            #CONFIG
            __CONFIG _CONFIG1, _FCMEN_OFF & _IESO_OFF & _FOSC_INTOSC & _PLLEN_OFF & _WDTE_SWDTEN & _MCLRE_OFF & _CP_OFF & _BOREN_OFF & _PWRTE_OFF
            __CONFIG _CONFIG2, _LVP_OFF
            #ENDCONFIG
    
            OSCCON = %01111000
                    ' x------- SPLLEN: don't care when _PLLEN_OFF in config fuse
                    ' -1111--- Internal clock = 16MHz
                    ' -----x-- Unimplemented
                    ' ------00 System Clock Source = Determined by Config Word
            
            DEFINE OSC 16 ' Tell PBP we use a 16MHz Clock
    Was ok the first time I posted it, messed when use the QuickEdit... so before posting it again, I switched to Advanced Moxe...paste the code again and we're up! Damn
    Steve

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

  6. #6
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    I am trying to use a 16f1847 and can not get it to blink an led I am sure this is a config problem but just can't make it work. this is my config and blink program below.

    Thanks!


    ;----[16LF1847 Hardware Configuration]------------------------------------------
    #IF __PROCESSOR__ = "16LF1847"
    #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _FOSC_INTOSC ; INTOSC oscillator: I/O function on CLKIN pin
    cfg1&= _WDTE_ON ; WDT enabled
    cfg1&= _PWRTE_OFF ; PWRT disabled
    cfg1&= _MCLRE_OFF ; MCLR/VPP pin function is digital input
    cfg1&= _CP_OFF ; Program memory code protection is disabled
    cfg1&= _CPD_OFF ; Data memory code protection is disabled
    cfg1&= _BOREN_ON ; Brown-out Reset enabled
    cfg1&= _CLKOUTEN_OFF ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
    cfg1&= _IESO_ON ; Internal/External Switchover mode is enabled
    cfg1&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled
    __CONFIG _CONFIG1, cfg1

    cfg2 = _WRT_OFF ; Write protection off
    cfg2&= _PLLEN_OFF ; 4x PLL disabled
    cfg2&= _STVREN_ON ; Stack Overflow or Underflow will cause a Reset
    cfg2&= _BORV_19 ; Brown-out Reset Voltage (Vbor), low trip point selected.
    cfg2&= _LVP_OFF ; High-voltage on MCLR/VPP must be used for programming
    __CONFIG _CONFIG2, cfg2

    #ENDCONFIG

    #ENDIF

    #IFNDEF MCU_FOUND
    #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF

    OSCCON = %00001111
    ADCON1 = %11111111 'PROBABLY NOT RIGHT??
    ANSELA = 0 'PROBABLY NOT RIGHT??

    MainLoop:

    LED VAR PORTA.0
    LED2 VAR PORTA.0
    HighLED
    High LED2
    Pause 500
    Low LED
    Low LED2
    Pause 500
    Goto MainLoop

  7. #7
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    Just a casual observation; you're posting to a 9 year old thread instead of starting your own. In this 9 year old thread you can plainly see the working examples listed in previous posts:
    Code:
    #CONFIG        __CONFIG _CONFIG1, _FCMEN_OFF & _IESO_OFF & _FOSC_INTOSC & _PLLEN_OFF & _WDTE_SWDTEN & _MCLRE_OFF & _CP_OFF & _BOREN_OFF & _PWRTE_OFF        __CONFIG _CONFIG2, _LVP_OFF        #ENDCONFIG
    You list your own thing and wonder why it doesn't work for you. Am I being overly critical?!?

Members who have read this thread : 4

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