PPL setting for 18f27k42


+ Reply to Thread
Results 1 to 13 of 13

Thread: PPL setting for 18f27k4223 days old

  1. #1
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    129
    Thumbs Up
    Received: 8
    Given: 12
    Total Downloaded
    2.89 GB

    0 Not allowed!

    Default PPL setting for 18f27k42

    Hi
    I'm lazy tonight and tired of reading datasheets. Can someone tell me how to set the PLL of this device? Thanks in advance.
    Flosi Guğmundsson
    Reykjavík

Attention
×

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,347
    Thumbs Up
    Received: 42
    Given: 39
    Total Downloaded
    3.36 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    I tried to find the datasheet Flosi and failed. Either I'm getting too old to carry out a basic search or Microchip's website is useless.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    129
    Thumbs Up
    Received: 8
    Given: 12
    Total Downloaded
    2.89 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    I'm old too but found the datasheet. I've found the relevant chapter and done what what is told there and that does not work.
    Flosi Guğmundsson
    Reykjavík

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Setting PLL on a PIC18F27K42 device with internal oscillator using Proton

    If using an external crystal just switch on PLL within the config fuses. For the internal oscillator, a few SFRs need to be manipulated, but when they are operating, the newer 18FxxK devices are excellent at stability, and they contain 8K of RAM.

    See section 7 in the datasheet.

    One thing to remember with the 18FxxK42 devices is that with the extended RAM, the SFRs are also in high RAM and a new mnemonic has been added to the device to reach the high RAM, which is Moffl. This single mnemonic uses more code memory than the standard Movff mnemonic and operates a cycle longer, but the extra RAM is great.

    Here's a set of procedures that will alter the internal oscillator for different frequencies. It also shows the flexability that procedures now give to the Proton language:

    Code:
    '
    '   /\\\\\\\\\
    '  /\\\///////\\\
    '  \/\\\     \/\\\                                                 /\\\          /\\\
    '   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
    '    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
    '     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
    '      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
    '       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
    '        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
    '                                  Let's find out together what makes a PIC Tick!
    '
    ' Internal Oscillator procedures for a PIC18F27K42 device
    ' Written by Les Johnson for the Proton BASIC Compiler version 3.7.3.1 onwards
    '
        Device = 18F27K42
        Declare Xtal = 64
        
        Declare Hserial1_Baud = 115200
        Declare HRSOut1_Pin   = PORTC.6
     
    '----------------------------------------------------------------------------------------------------------
    ' Run the device's internal oscillator at 64MHz
    ' Input     : None 
    ' Output    : None
    ' Notes     : Waits for the oscillator to become stable
    ' 
    Proc Oscillator_64MHz() 
        OSCCON1 = $60               ' HFINTOSC, NDIV 1
        OSCCON3 = $00
        OSCEN   = $00   
        OSCFRQ  = $08               ' HFFRQ 64MHz
        OSCTUNE = $00
        While OSCSTATbits_HFOR = 0: Wend
    EndProc
    
    '----------------------------------------------------------------------------------------------------------
    ' Run the device's internal oscillator at 48MHz
    ' Input     : None 
    ' Output    : None
    ' Notes     : Waits for the oscillator to become stable
    ' 
    Proc Oscillator_48MHz() 
        OSCCON1 = $60               ' HFINTOSC, NDIV 1
        OSCCON3 = $00
        OSCEN   = $00   
        OSCFRQ  = $07               ' HFFRQ 48MHz
        OSCTUNE = $00
        While OSCSTATbits_HFOR = 0: Wend
    EndProc
    
    '----------------------------------------------------------------------------------------------------------
    ' Run the device's internal oscillator at 32MHz
    ' Input     : None 
    ' Output    : None
    ' Notes     : Waits for the oscillator to become stable
    ' 
    Proc Oscillator_32MHz() 
        OSCCON1 = $60               ' HFINTOSC, NDIV 1
        OSCCON3 = $00
        OSCEN   = $00   
        OSCFRQ  = $06               ' HFFRQ 32MHz
        OSCTUNE = $00
        While OSCSTATbits_HFOR = 0: Wend
    EndProc
    
    '----------------------------------------------------------------------------------------------------------
    ' Run the device's internal oscillator at 16MHz
    ' Input     : None 
    ' Output    : None
    ' Notes     : Waits for the oscillator to become stable
    ' 
    Proc Oscillator_16MHz() 
        OSCCON1 = $60               ' HFINTOSC, NDIV 1
        OSCCON3 = $00
        OSCEN   = $00   
        OSCFRQ  = $05               ' HFFRQ 16MHz
        OSCTUNE = $00
        While OSCSTATbits_HFOR = 0: Wend
    EndProc
    
    '----------------------------------------------------------------------------------------------------------
    ' The main program starts here
    ' Runs a loop transmitting text to a serial terminal
    ' If the terminal receives the correct text, the Baud is correct so the device operating frequency is correct
    
    Main:
        Oscillator_64MHz() 
        
        Do
            HRSOutLn "Hello World"
            DelayMS 100
        Loop
    
    '----------------------------------------------------------------------------------------------------------
    ' Setup the config fuses to operate the device with internal oscillator
    '
    Config_Start
        FEXTOSC  = Off              ' External Oscillator Selection->Oscillator not enabled
        RSTOSC   = HFINTOSC_1MHZ    ' With HFFRQ = 4MHz and CDIV = 4:1
        CLKOUTEN = Off              ' Clock out Enable bit->CLKOUT function is disabled
        PR1WAY   = On               ' PRLOCKED One-Way Set Enable bit->PRLOCK bit can be cleared and set only once
        CSWEN    = On               ' Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
        FCMEN    = On               ' Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled
        MCLRE    = EXTMCLR          ' MCLR Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR
        PWRTS    = PWRT_Off         ' Power-up timer selection bits->PWRT is disabled
        MVECEN   = Off              ' Multi-vector enable bit->Interrupt contoller does not use vector table to prioritze interrupts
        IVT1WAY  = On               ' IVTLOCK bit One-way set enable bit->IVTLOCK bit can be cleared and set only once
        LPBOREN  = Off              ' Low Power BOR Enable bit->ULPBOR disabled
        BOREN    = SBORDIS          ' Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored
        BORV     = VBOR_2P45        ' Brown-out Reset Voltage Selection bits->Brown-out Reset Voltage (VBOR) set to 2.45V
        ZCD      = Off              ' ZCD Disable bit->ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCOn
        PPS1WAY  = Off              ' PPSLOCK bit One-Way Set Enable bit->PPSLOCK bit can be cleared and set
        STVREN   = On               ' Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset
        Debug    = Off              ' Debugger Enable bit->Background debugger disabled
        XINST    = Off              ' Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled
        WDTCPS   = WDTCPS_31        ' WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS
        WDTE     = Off              ' WDT operating mode->WDT Disabled; SWDTEN is ignored
        WDTCWS   = WDTCWS_7         ' WDT Window Select bits->window always open (100%); software control; keyed access not required
        WDTCCS   = SC               ' WDT input clock selector->Software Control
        BBSIZE   = BBSIZE_512       ' Boot Block Size selection bits->Boot Block size is 512 words
        BBEN     = Off              ' Boot Block enable bit->Boot block disabled
        SAFEN    = Off              ' Storage Area Flash enable bit->SAF disabled
        WRTAPP   = Off              ' Application Block write protection bit->Application Block not write protected
        WRTB     = Off              ' Configuration Register Write Protection bit->Configuration registers (300000-30000Bh) not write-protected
        WRTC     = Off              ' Boot Block Write Protection bit->Boot Block (000000-0007FFh) not write-protected
        WRTD     = Off              ' Data EEPROM Write Protection bit->Data EEPROM not write-protected
        WRTSAF   = Off              ' SAF Write protection bit->SAF not Write Protected
        LVP      = Off              ' Low Voltage Programming Disabled
        Cp       = Off              ' PFM and Data EEPROM Code Protection bit->PFM and Data EEPROM code protection disabled
    Config_End
    Last edited by top204; 30th October 2019 at 13:05.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: Setting PLL on a PIC18F27K42 device with internal oscillator using Proton

    And you are right Charlie.... The Microchip website is absolutely dreadful, which is now typical of the internet unfortunately. :-(

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,215
    Thumbs Up
    Received: 74
    Given: 180
    Total Downloaded
    5.15 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    Here's an app for setting PPS on most PIC devices https://sourceforge.net/projects/pps-tool/. It uses XML files from uhggg Mplabx but I seem to remember at least one version included them so no need to install that horrible mess from mc.

    Edit Seems like the latest version doesn't have the XML files. I'm pretty sure the version included in GCB does have them but of course none of the highly ethical Proton users would install an app just to save them the huge pina of installing Mplabx. I'll dig around an see if I can find them.

    YAEdit. Seems like the version in GCB only has/supports 18F PIC devices but that doesn't matter cause the PPS tool for Proton covers 24x.
    Last edited by towlerg; 30th October 2019 at 15:32.
    George.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #7
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    PLL Geoerge, not PPS. :-)

    I've looked at that program and it has a few flaws in it. One of the major flaws is that it uses Microchip XML files and they sometimes change them when they do an update to MPLABX! I fell into that trap when creating teh compiler's PPI and def files using Microchip's files. Then they totally changed their internal structure and it created havok with the PPI creator program but so subtly that I did not notice at first.

    Altering PPS (Peripheral Pin Select) is quite straightforward but Microchip being Microchip have changed how it operates on some devices, so setting up PPS for one family will differ for the next. :-(

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #8
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,215
    Thumbs Up
    Received: 74
    Given: 180
    Total Downloaded
    5.15 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    Given Les's remarks perhaps use the tools and then manually confirm the results. FWIW I've used it for 18F27K42 and it worked.

    To be fair, I'm not sure I would call using files from the manufacturer a major flaw, surely better than manually creating the files with the possible transcription errors.

    Try it, if it works super, if it doesn't what harm?

    PLL Geoerge, not PPS. :-)
    You can blame the thread creator for that one :-)
    Last edited by towlerg; 30th October 2019 at 15:47.
    George.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #9
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    129
    Thumbs Up
    Received: 8
    Given: 12
    Total Downloaded
    2.89 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    Quote Originally Posted by towlerg View Post

    You can blame the thread creator for that one :-)
    Yes, I'm to blame for that.

    To clarify my problem I was under the impression that these two lines in config:

    Code:
    Config FEXTOSC = HS    ;HS (crystal oscillator) above 8 MHz; PFM set to high power
    Config RSTOSC = EXTOSC_4PLL    ;EXTOSC with 4x PLL, with EXTOSC operating per FEXTOSC bits
    and this one in mainprog

    Code:
    OSCCON1 = $20


    would do the trick, but it does not.
    Flosi Guğmundsson
    Reykjavík

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #10
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,215
    Thumbs Up
    Received: 74
    Given: 180
    Total Downloaded
    5.15 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    Even a simple task like getting the oscillator running is challanging on mc newer devices.

    Here's my test blinky for 18F27K42, it's 64 MHz, no crystal

    Code:
        Device = 18F27K42
      Xtal = 64
      All_Digital = True
       
      Symbol LED = PORTA.4          
      
      ADCON0 = %00000000                 ' Disable ADC
      OSCCON1 = %01100000                ' Primary OSC 64Mhz 
      OSCFRQ = %00001000                 ' 64MHz 
                                        
      TRISA = %11101111                  ' Set unused ports to input
      TRISB = %11111111                  ' Set unused ports to input
      TRISC = %11111111                  ' Set unused ports to input
     
      DelayMS 100                        ' let everything settle
    
      LED = 1                
       
      While 1 = 1
        DelayMS 500
        Toggle LED
      Wend 
    
      Stop
      
      Config_Start
        FEXTOSC = OFF               ; Oscillator not enabled
        RSTOSC = HFINTOSC_64MHZ     ; HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1
        CLKOUTEN = OFF             ; CLKOUT function is disabled
        PR1WAY = OFF               ; PRLOCK bit can be set and cleared repeatedly
        CSWEN = On                 ; Writing to NOSC and NDIV is allowed
        FCMEN = OFF                 ; Fail-Safe Clock Monitor disabled
        MCLRE = INTMCLR             ; If LVP = 0, MCLR pin function is port defined function; If LVP =1, RE3 pin fuction is MCLR
        PWRTS = PWRT_1             ; PWRT set at 1ms
        MVECEN = OFF               ; Interrupt contoller does not use vector table to prioritze interrupts
        IVT1WAY = OFF               ; IVTLOCK bit can be cleared and set repeatedly
        LPBOREN = On               ; ULPBOR enabled
        BOREN = SBORDIS             ; Brown-out Reset enabled , SBOREN bit is ignored
        BORV = VBOR_2P7             ; Brown-out Reset Voltage (VBOR) set to 2.7V
        ZCD = OFF                   ; ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
        PPS1WAY = OFF               ; PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)
        STVREN = On                 ; Stack full/underflow will cause Reset
        Debug = OFF                 ; Background debugger disabled
        XINST = OFF                 ; Extended Instruction Set and Indexed Addressing Mode disabled
        WDTCPS = WDTCPS_31         ; Divider ratio 1:65536; software control of WDTPS
        WDTE = OFF                 ; WDT Disabled; SWDTEN is ignored
        WDTCWS = WDTCWS_7           ; window always open (100%); software control; keyed access not required
        WDTCCS = SC                 ; Software Control
        BBSIZE = BBSIZE_512         ; Boot Block size is 512 words
        BBEN = OFF                 ; Boot block disabled
        SAFEN = On                 ; SAF enabled
        WRTAPP = OFF               ; Application Block not write protected
        WRTB = OFF                 ; Configuration registers (300000-30000Bh) not write-protected
        WRTC = OFF                 ; Boot Block (000000-0007FFh) not write-protected
        WRTD = OFF                 ; Data EEPROM not write-protected
        WRTSAF = OFF               ; SAF not Write Protected
        LVP = OFF                   ; HV on MCLR/VPP must be used for programming
        Cp = OFF                   ; PFM and Data EEPROM code protection disabled
      Config_End
    George.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #11
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    129
    Thumbs Up
    Received: 8
    Given: 12
    Total Downloaded
    2.89 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    It turns out that my were in relation to serial tramsmission. If I use 19200 baud or faster my setup above works.

    Code:
    
    
    
        Device = 18F27K42
        Declare Xtal 64
        OSCCON1 = $20
        While OSCSTATbits_EXTOR = 0 : Wend
        Declare Hserial_Baud 19200    
    
    
        Symbol LED PORTC.2
        Output LED         
    
    
        Do
            Toggle LED
            HRSOut "pic18f27k42",13
            DelayMS 500
        Loop
        End
    
    
    
    
    
    
    Config_Start
        FEXTOSC        = HS            ' (crystal oscillator) above 8 MHz; PFM set to high power
        RSTOSC        = EXTOSC_4PLL    ' EXTOSC with 4x PLL, with EXTOSC operating per FEXTOSC bits
        CLKOUTEN    = OFF            ' CLKOUT function is disabled
        PR1WAY        = OFF            ' PRLOCK bit can be set and cleared repeatedly
        CSWEN        = On            ' Writing to NOSC and NDIV is allowed
        FCMEN        = On            ' Fail-Safe Clock Monitor enabled
        MCLRE        = EXTMCLR        ' If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR 
        PWRTS        = PWRT_OFF        ' PWRT is disabled
        MVECEN        = On            ' Multi-vector enabled, Vector table used for interrupts
        IVT1WAY        = On            ' IVTLOCK bit can be cleared and set only once
        LPBOREN        = OFF            ' ULPBOR disabled
        BOREN        = SBORDIS        ' Brown-out Reset enabled , SBOREN bit is ignored
        BORV        = VBOR_2P45        ' Brown-out Reset Voltage (VBOR) set to 2.45V
        ZCD            = OFF            ' ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON
        PPS1WAY        = OFF            ' PPSLOCK bit can be set and cleared repeatedly (subject to the unlock sequence)
        STVREN        = OFF            ' Stack full/underflow will not cause Reset
        Debug        = OFF            ' Background debugger disabled
        XINST        = OFF            ' Extended Instruction Set and Indexed Addressing Mode disabled
        WDTCPS        = WDTCPS_31        ' Divider ratio 1:65536; software control of WDTPS
        WDTE        = OFF            ' WDT Disabled; SWDTEN is ignored
        WDTCWS        = WDTCWS_7        ' window always open (100%); software control; keyed access not required
        WDTCCS        = SC            ' Software Control
        BBSIZE        = BBSIZE_512    ' Boot Block size is 512 words
        BBEN        = OFF            ' Boot block disabled
        SAFEN        = OFF            ' SAF disabled
        WRTAPP        = OFF            ' Application Block not write protected
        WRTB        = OFF            ' Configuration registers (300000-30000Bh) not write-protected
        WRTC        = OFF            ' Boot Block (000000-0007FFh) not write-protected
        WRTD        = OFF            ' Data EEPROM not write-protected
        WRTSAF        = OFF            ' SAF not Write Protected
        LVP            = OFF            ' HV on MCLR/VPP must be used for programming
        Cp            = OFF            ' PFM and Data EEPROM code protection disabled
    Config_End

    I also experimented with internal oscillator:

    Code:
        Device = 18F27K42
        Declare Xtal = 4
        
        Declare Hserial1_Baud = 19200
        Declare HRSOut1_Pin   = PORTC.6
    
    
    '    ----------------------------------------------------------------------------
    '    Run the device's internal oscillator
    '    Input    : HFFRQ_xxMHz
    '    Output    : None
    '    Notes    : Waits for the oscillator to become stable
    '
        
        Symbol HFFRQ_01MHz        $00
        Symbol HFFRQ_02MHz        $01
        Symbol HFFRQ_04MHz        $02
        Symbol HFFRQ_08MHz        $03
        Symbol HFFRQ_12MHz        $04
        Symbol HFFRQ_16MHz        $05
        Symbol HFFRQ_32MHz        $06
        Symbol HFFRQ_48MHz        $07
        Symbol HFFRQ_64MHz        $08
          
    $define runOscillator(HFFRQ)    ' 
        OSCCON1 = $60                '
        OSCCON3 = $00                '
        OSCEN   = $00                '   
        OSCFRQ  = HFFRQ                '
        OSCTUNE = $00                '
        While OSCSTATbits_HFOR = 0: Wend
    
    
        runOscillator(HFFRQ_04MHz)
    
    
    '    ----------------------------------------------------------------------------
    '    The main program starts here
    '    Runs a loop transmitting text to a serial terminal
    '    If the terminal receives the correct text, the Baud is correct 
    '    so the device operating frequency is correct
    
    
    
    
        Dim bTmp As Byte
    
    
        bTmp = 10
        For bTmp = bTmp To 0 Step - 1
            HRSOutLn "Hello World"
            DelayMS 100
        Next
    
    
    '-------------------------------------------------------------------------------
    ' Setup the config fuses to operate the device with internal oscillator
    '
    Config_Start
        FEXTOSC  = Off              ' External Oscillator Selection->Oscillator not enabled
        RSTOSC   = HFINTOSC_1MHZ    ' With HFFRQ = 4MHz and CDIV = 4:1
        CLKOUTEN = Off              ' Clock out Enable bit->CLKOUT function is disabled
        PR1WAY   = On               ' PRLOCKED One-Way Set Enable bit->PRLOCK bit can be cleared and set only once
        CSWEN    = On               ' Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
        FCMEN    = On               ' Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled
        MCLRE    = EXTMCLR          ' MCLR Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR
        PWRTS    = PWRT_Off         ' Power-up timer selection bits->PWRT is disabled
        MVECEN   = Off              ' Multi-vector enable bit->Interrupt contoller does not use vector table to prioritze interrupts
        IVT1WAY  = On               ' IVTLOCK bit One-way set enable bit->IVTLOCK bit can be cleared and set only once
        LPBOREN  = Off              ' Low Power BOR Enable bit->ULPBOR disabled
        BOREN    = SBORDIS          ' Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored
        BORV     = VBOR_2P45        ' Brown-out Reset Voltage Selection bits->Brown-out Reset Voltage (VBOR) set to 2.45V
        ZCD      = Off              ' ZCD Disable bit->ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCOn
        PPS1WAY  = Off              ' PPSLOCK bit One-Way Set Enable bit->PPSLOCK bit can be cleared and set
        STVREN   = On               ' Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset
        Debug    = Off              ' Debugger Enable bit->Background debugger disabled
        XINST    = Off              ' Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled
        WDTCPS   = WDTCPS_31        ' WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS
        WDTE     = Off              ' WDT operating mode->WDT Disabled; SWDTEN is ignored
        WDTCWS   = WDTCWS_7         ' WDT Window Select bits->window always open (100%); software control; keyed access not required
        WDTCCS   = SC               ' WDT input clock selector->Software Control
        BBSIZE   = BBSIZE_512       ' Boot Block Size selection bits->Boot Block size is 512 words
        BBEN     = Off              ' Boot Block enable bit->Boot block disabled
        SAFEN    = Off              ' Storage Area Flash enable bit->SAF disabled
        WRTAPP   = Off              ' Application Block write protection bit->Application Block not write protected
        WRTB     = Off              ' Configuration Register Write Protection bit->Configuration registers (300000-30000Bh) not write-protected
        WRTC     = Off              ' Boot Block Write Protection bit->Boot Block (000000-0007FFh) not write-protected
        WRTD     = Off              ' Data EEPROM Write Protection bit->Data EEPROM not write-protected
        WRTSAF   = Off              ' SAF Write protection bit->SAF not Write Protected
        LVP      = Off              ' Low Voltage Programming Disabled
        Cp       = Off              ' PFM and Data EEPROM Code Protection bit->PFM and Data EEPROM code protection disabled
    Config_End
    Flosi Guğmundsson
    Reykjavík

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #12
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,215
    Thumbs Up
    Received: 74
    Given: 180
    Total Downloaded
    5.15 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    Most odd that high speed async but not low.

    I don't know is this is relevant or even current but I found that to achieve 9600 baud on an internal 64Mhz clock I had ti apply the following work around
    Code:
                ' ***** work around for K42 - remove when issue resolved
                U1CON0 = %00110000                           ' BRGS=0 ABDEN=0 TXEN=1 RXEN=1 Mode=0000 (8bit async)
                U1CON1 = %10000000                           ' SerialEn=1 unimp=00 WUE=0 RXBIMD=0 unimp=0 BRKOVR=0 SENDB=0
                While U1FIFO.3 = 0                           ' RXIDL = bit 3 1 when idle
                Wend                                         '
                U1BRGH = 1                                   ' if idle set for 9600 ie 413 @ 64mhz
                U1BRGL = $9D
    George.

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #13
    Member flosigud's Avatar
    Join Date
    Oct 2013
    Posts
    129
    Thumbs Up
    Received: 8
    Given: 12
    Total Downloaded
    2.89 GB

    0 Not allowed!

    Default Re: PPL setting for 18f27k42

    No worries. I'm more interested in higher speeds.
    Flosi Guğmundsson
    Reykjavík

  • Attention
    ×

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

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

       

    Similar Threads

    1. Still failng with 18F27K42
      By towlerg in forum Projects discussion
      Replies: 0
      Last Post: 14th November 2018, 00:53
    2. Replies: 19
      Last Post: 14th July 2018, 22:07
    3. Setting up A/D 18F45K80
      By chuckieboy in forum The Lounge
      Replies: 24
      Last Post: 1st September 2012, 00:56
    4. [SOLVED !] Xtal setting
      By nigelb in forum Proton Plus Compiler v3
      Replies: 20
      Last Post: 19th January 2010, 16:54

    Members who have read this thread since 12th November 2019, 05:33 : 0

    Actions :  (Set Date)  (Clear Date)

    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