16F18877 CONFIG with PPS register settings


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,956

    Default 16F18877 CONFIG with PPS register settings

    32MHz internal

    Config:
    Code:
    #CONFIG
        __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
        __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
        __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
        __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
        __config _CONFIG5, _CP_OFF & _CPD_OFF
    #ENDCONFIG
    Oscillator:
    Code:
    DEFINE OSC 32
    
        OSCCON1 = %01100010
    '       bit 7   n/a
    '           6-4 NOSC    New Oscillator Source Request bits
    '                   110     HFINTOSC
    '           3-0 NDIV    New Divider Selection Request bits
    '                   0010    Clock divider = 4
    
        OSCCON3 = %00000000                 ' Default values
    
        OSCEN = %00000000                   ' Default values
    
        OSCFRQ = %00000110
    '       bit 7-3 n/a
    '           2-0 HFFRQ   Frequency Selection bits
    '                   110     32 MHz
    
        OSCTUNE = %00000000                 ' Default values
    PPS pin definitions to use CCP3 and CCP4 on Ports D2 and D3 respectively:
    Code:
    PinD2   CON %011010                     ' Datasheet table 13-2
    PinD3   CON %011011
    CCP3PPS = PinD2                         ' CCP3 Peripheral input selection
    CCP4PPS = PinD3                         ' CCP4 Peripheral input selection
    
    PeripheralCCP3  CON %001011             ' Datasheet table 13-3
    PeripheralCCP4  CON %001100
    RD2PPS = PeripheralCCP3                 ' Pin D2 output source selection
    RD3PPS = PeripheralCCP4                 ' Pin D3 output source selection
    HPWM on pins D2 and D3:
    Code:
        HPWM 3,160,1953                 ' Sample Pulses
        HPWM 4,180,1953
    Thanks go to TimB and Top204 on the Proton forum (that's where I got the Config from):
    https://protoncompiler.com/index.php?topic=528.0
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Aug 2011
    Posts
    439


    Did you find this post helpful? Yes | No

    Default Re: 16F18877 CONFIG with PPS register settings

    With those config1 settings you really shouldn't need to program any of the osc registers in code... it should run at 32Mhz at startup

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,956


    Did you find this post helpful? Yes | No

    Default Re: 16F18877 CONFIG with PPS register settings

    Yup. I can confirm it will work without the register definitions in this case (LCDOUT and heartbeat LED working properly).
    Last edited by Demon; - 28th August 2024 at 22:20.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,956


    Did you find this post helpful? Yes | No

    Default Re: 16F18877 CONFIG with PPS register settings

    NOTE: When moving a feature away from a pin, make sure to clear the PPS register for that pin.

    Code:
    RB5PPS = 0                              ' Disable CCP3
    RB0PPS = 0                              ' Disable CCP4
    Or else you risk having all sorts of annoying surprises; like having a regular pulse coming out of what you thought was an input pin.

    In my case, I moved CCP3 and CCP4 to other pins and was trying to use B0 and B5 for a rotary encoder signal. Took me WAAAAY too long to realize what was going on, but a quick google and Ric over at Microchip had the answer:

    https://forum.microchip.com/s/topic/...ment=P-2930284
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. 18F4550 Config settings
    By Ioannis in forum USB
    Replies: 5
    Last Post: - 16th December 2021, 18:43
  2. Replies: 1
    Last Post: - 8th March 2013, 09:29
  3. PIC16F886 Register Settings
    By aherrera in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2009, 17:52
  4. Config settings
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th December 2007, 18:24
  5. Register Settings
    By Archangel in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th September 2007, 00:28

Members who have read this thread : 10

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