Config & Oscon settings 16F1825


Closed Thread
Results 1 to 8 of 8

Hybrid View

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

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

  3. #3
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Config & Oscon settings 16F1825

    This fixed my problem. I did not notice I had ticked 16fl1847 not 16f1847 in MeConfig . I changed "OSCCON = %11100000" to "OSCCON = %01110000" and added "DEFINE OSC 8". I am glad I figured it out before anyone answered.




    ;----[16F1847 Hardware Configuration] From MeConfig--------------------------
    #IF __PROCESSOR__ = "16F1847"
    #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _FOSC_INTOSC ; INTOSC oscillator: I/O function on CLKIN pin
    cfg1&= _WDTE_OFF ; WDT disabled
    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_OFF ; Brown-out Reset disabled
    cfg1&= _CLKOUTEN_OFF ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
    cfg1&= _IESO_OFF ; Internal/External Switchover mode is disabled
    cfg1&= _FCMEN_OFF ; Fail-Safe Clock Monitor is disabled
    __CONFIG _CONFIG1, cfg1

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

    #ENDCONFIG

    #ENDIF

    ;----[Verify Configs have been specified for Selected Processor]----------------
    ; Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
    #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF


    ANSELA = 0 ' Turn off analog port A
    ANSELB = 0 ' Turn off analog port B
    CM1CON0 = 0 ' Comparators off.
    CM1CON1 = 0
    CM2CON0 = 0 ' Comparators off.
    CM2CON1 = 0
    CPSCON0 = 0 ' Capacitive sense module off.
    TRISB = %00000000
    OSCCON = %01110000
    ADCON1 = %11111111
    DEFINE OSC 8

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