18F26K80 Serial setting sanity check and 4xPLL.


+ Reply to Thread
Results 1 to 21 of 21
  1. #1

    Default 18F26K80 Serial setting sanity check and 4xPLL.

    Does this look right for a pic runing at 80mhz? Thanks (I appreciate it is overclocked)

    DEFINE HSER_RCSTA 90h 'Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h 'Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 'Clear overflow automatically
    DEFINE HSER_SPBRG 90 '57600 Baud @ 80MHz, -0.064% (346 Decimal = $15A)
    define HSER_SPBRGH 1
    BAUDCON1.3 = 1 'Enable 16 bit baudrate generator


    I'm also trying to set the PIC to activate the PLL wiith a 20mhz external resonator. It seems stuck at 1/4 speed.
    Note the program runs fine at 64mhz with the internal oscillator and 4 xPLL but I can't seem to get the PLL enabled with an external resonator.


    Code:
        CONFIG  RETEN = OFF           ; Ultra low-power regulator is Enabled (Controlled by SRETEN bit)
        CONFIG  INTOSCSEL = HIGH   ; High power mode during Sleep
        CONFIG  SOSCSEL = DIG        ; Disabled RC0 & RC1 I/0
        CONFIG  XINST = OFF           ; Disabled
        CONFIG  FOSC = HS2            ; External 20mhz Resonator
        CONFIG  PLLCFG = ON           ; Enabled
    OSCCON = %00000000 'External Resonator
    OSCCON2 = %00000000 'Clear
    OSCTUNE = %01000000 'Enable PLL x 4 = 80mhz


    Comments?
    Last edited by retepsnikrep; - 27th July 2022 at 17:24.

  2. #2
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Overclocking it 25% might be asking a lot, but assuming it's running at 80MHz those serial settings look to be correct.

    You might have better luck powering up @ 20MHZ and then enabling the PLL by setting OSCTUNE = $40 once things are up and running.
    I'd start with
    Code:
    config FOSC = HS2         ; HS oscillator (High power, 16 MHz - 25 MHz)
    config PLLCFG = OFF       ; Disabled
    config FCMEN = OFF        ; Disabled
    config IESO = OFF         ; Disabled
    config PWRTEN = ON        ; Enabled

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    No change with that so far. Hmmm??

  4. #4
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    How are you verifying the freq?

    Could you post your whole setup, including the config?

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    The code is massive.

    I have a 1hz led timer1 interrupt flasher routine.

    It's only working at 1/4 speed with the 20mhz resonator but works correctly at 64mhz with the internal osc.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Code:
    '-------------------------- General 18F26K80 configuration ---------------------
    
    #CONFIG
        CONFIG  RETEN = OFF           ; Ultra low-power regulator is Enabled (Controlled by SRETEN bit)
        CONFIG  INTOSCSEL = HIGH      ; High power mode during Sleep
        CONFIG  SOSCSEL = DIG         ; Disabled RC0 & RC1 I/0
        CONFIG  XINST = OFF           ; Disabled
        CONFIG  FOSC = HS2            ; External 20mhz Resonator
        CONFIG  PLLCFG = ON           ; Enabled
        CONFIG  FCMEN = OFF           ; Disabled
        CONFIG  IESO = OFF            ; Disabled
        CONFIG  PWRTEN = OFF          ; Disabled
        CONFIG  BOREN = OFF           ; Disabled 
        CONFIG  BORV = 3              ; 1.8V
        CONFIG  BORPWR = ZPBORMV      ; ZPBORMV instead of BORMV is selected
        CONFIG  WDTEN = OFF           ; WDT disabled in hardware; SWDTEN bit disabled
        CONFIG  WDTPS = 512           ; WDTPS 1:256  = 1.024 Second Timeout
        CONFIG  CANMX = PORTB         ; ECAN TX and RX pins are located on RB2 and RB3, respectively
        CONFIG  MSSPMSK = MSK7        ; 7 Bit address masking mode
        CONFIG  MCLRE = OFF           ; MCLR Enabled, RE3 Disabled
        CONFIG  STVREN = ON           ; Enabled
        CONFIG  BBSIZ = BB2K          ; 2K word Boot Block size
        CONFIG  CP0 = OFF             ; Disabled
        CONFIG  CP1 = OFF             ; Disabled
        CONFIG  CP2 = OFF             ; Disabled
        CONFIG  CP3 = OFF             ; Disabled
        CONFIG  CPB = OFF             ; Disabled
        CONFIG  CPD = OFF             ; Disabled
        CONFIG  WRT0 = OFF            ; Disabled
        CONFIG  WRT1 = OFF            ; Disabled
        CONFIG  WRT2 = OFF            ; Disabled
        CONFIG  WRT3 = OFF            ; Disabled
        CONFIG  WRTC = OFF            ; Disabled
        CONFIG  WRTB = OFF            ; Disabled
        CONFIG  WRTD = OFF            ; Disabled
        CONFIG  EBTR0 = OFF           ; Disabled
        CONFIG  EBTR1 = OFF           ; Disabled
        CONFIG  EBTR2 = OFF           ; Disabled
        CONFIG  EBTR3 = OFF           ; Disabled
        CONFIG  EBTRB = OFF           ; Disabled
    #ENDCONFIG  
    
    '*******************************************************************************
    '**************************  PBP Basic Defines  ********************************
    '*******************************************************************************  
    
    DEFINE OSC 40           '80mhz  (If overclocking at 96mhz set define to 48mhz ot if 80mhz set at 40mhz)
    DEFINE NO_CLRWDT 1      'No Clear WDT Instructions added
    
    '***********************   Direct Pic Register Settings ************************
    
    OSCCON  = %00001000     'External Resonator  
    OSCCON2 = %00000000     'Clear
    HLVDCON = %00000000		'HLVCON Disabled   
    
    T1CON = %00110000       'Timer 1 Setup. 
    'TRISA = %11111111 		'SET PORTA.0-7 Inputs
    TRISA = %00111111 		'SET PORTA.0-5 Inputs 6,7 Outputs
    TRISB = %00001000		'SET PORTB.3 Input rest as Outputs 
    TRISC = %10010000		'SET PORTC.4,7 Inputs rest as Outputs
    
    ANCON0 = %00000001      'Analog Inputs on A0
    ANCON1 = %00000000      'No Analog Inputs 
    
    ADCON2 = %00011110	    'SETUP ADC FOSC/64 LEFT JUSTIFY TAD 6  
    ADCON1 = %00000000	    'SETUP ADC SET REFV to VDD & VSS AN0 
    ADCON0 = %00000011	    'SETUP ADC & ENABLE ADC MODULE & START CONVERSION    
    
    SLRCON = %00000000      'Ports slew at standard rate!
    
    SSPSTAT = %11000000     'Configure SPI Module      
    SSPCON1 = %00101010     'Enable SPI Master Mode Fosc/8 (10mhz) Clock idle low
    SSPCON2 = %00000000     'Configure SPI Module
    
    'bit 3-0 SSPM<3:0>: Master Synchronous Serial Port Mode bits(3)
    
    '0010 = SPI Master mode: clock = FOSC/64  (1mhz)
    '0001 = SPI Master mode: clock = FOSC/16  (4mhz)
    '1010 = SPI Master mode: clock = FOSC/8   (8mhz at 64fosc) (10mhz at 80fosc) (12mhz at 96fosc)
    '0000 = SPI Master mode: clock = FOSC/4   (16mhz)  (Doesn't Work!)      
    
    'Eusart 1 (64mhz FOSC)  'Serial/Video Comms (16mhz x 4)
    'DEFINE HSER_RCSTA 90h   'Enable serial port & continuous receive
    'DEFINE HSER_TXSTA 24h   'Enable transmit, BRGH = 1
    'DEFINE HSER_CLROERR 1   'Clear overflow automatically
    'DEFINE HSER_SPBRG 22    '57600 Baud @ 64MHz, -0.44%   (277 Decimal = $115) 
    'define HSER_SPBRGH 1
    'BAUDCON1.3 = 1          'Enable 16 bit baudrate generator
    
    ''Eusart 1 (80mhz FOSC)  'Serial/Video Comms (20mhz x 4)
    DEFINE HSER_RCSTA 90h   'Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h   'Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1   'Clear overflow automatically
    DEFINE HSER_SPBRG 90    '57600 Baud @ 80MHz, -0.064%   (346 Decimal = $15A) 
    define HSER_SPBRGH 1
    BAUDCON1.3 = 1          'Enable 16 bit baudrate generator   
    
    ''Eusart 1 (96mhz FOSC)  'Serial/Video Comms (24mhz x 4)
    'DEFINE HSER_RCSTA 90h   'Enable serial port & continuous receive
    'DEFINE HSER_TXSTA 24h   'Enable transmit, BRGH = 1
    'DEFINE HSER_CLROERR 1   'Clear overflow automatically
    'DEFINE HSER_SPBRG 160   '57600 Baud @ 96MHz, -0.080%   (416 Decimal = $1A0) 
    'define HSER_SPBRGH 1
    'BAUDCON1.3 = 1          'Enable 16 bit baudrate generator

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I tried changing chip, no difference.

    Still stuck at 1/4 speed and PLL not activating.

    Hmm I wonder if my resonator marked 20mhz really is a 20mhz one!!

  8. #8
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I don't have any 20MHz xtals to try.

    FWIW, I was able to get an 18F26K80 running at 80MHz with an external 20MHz osc into OSC1/CLKIN (using CONFIG = EC3).
    The 4x PLL worked using either CONFIG PLLCFG = ON or CONFIG PLLCFG = OFF and setting OSCTUNE.PLLEN = 1.

    I didn't even have a cap on the VDDCORE pin, and it worked with VDD down to 3V.

    According to the datasheet EC and HS modes use the same clock tree, so I would think if you're using HS2 mode with a 20MHz xtal it would work too.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Hi all I'm still fiddling with this.

    Any new ideas on why it might not run at 80mhz with external resonator?

  10. #10
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Did you try powering up with the PLL off and then turning it on later?

    Try changing some of the CONFIG settings
    Code:
        CONFIG FOSC = HS2		; HS oscillator (High power, 16 MHz - 25 MHz)
        CONFIG PLLCFG = OFF		; Disabled
        CONFIG PWRTEN = ON		; Enabled
        CONFIG BOREN = SBORDIS	; Enabled in hardware, SBOREN disabled
        CONFIG BORV = 0		; 3.0V
    and then at startup
    Code:
     
    '***********************   Direct Pic Register Settings ************************
    OSCCON  = %00000000     'SCS[1:0] = 00, Default primary oscillator
    OSCCON2 = %00000000     'Clear
    
    ' enable the 4xPLL
    delayms 100	' allow some time for osc and power to stabilize
    OSCTUNE.6 = 1	' PLLEN = 1

  11. #11
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I had issues with 20mhz external oscillator as well - needed to fine tune capacitors for it to run.
    Don't remember exactly, but had to replace recommended 22pf with 10pf or something like that.

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    may be you have too much stray capacitance on your pcb or breadboard.

    Ioannis

  13. #13
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    2 out of 2 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Crystals, crystal oscillators and ceramic resonators are three different things.
    • Crystals needs load capacitors (whose value CAN sometimes be picky). The crystal uses the oscillator inside the PIC.
    • Crystal oscillators have the crystal, load capacitors and oscillator in one package and drives the CLKIn pin of the PIC at roughly TTL levels. The oscillator IN the PIC is not used.
    • Ceramic resonator, like crystal oscillators, does not need external capacitors but unlike crystal oscillator, they do use the oscillator inside the PIC.

    The PLL is a block that is tacked on after the oscillator or CLKIn signal.

    Apparently Peter is using a resonator and if that resonator works when the PIC is configured to NOT use the PLL, ie it's configured to run and does run at 20MHz then I'd say the external circuitry is OK. As we know, the PIC is specified to run at up to 64MHz so expecting it to run at 80MHz might be a bit of a stretch. The fact that it works on one device doesn't mean it works on all devices. Then again, I would expect it to either not run at all or start up and randomly crash - not run at the base frequency.

    A) Get it to work at whatever frequency resonator you put at it's input.
    B) Get the PLL to work while using an inout frequency that does nor overclock the PIC.
    C) Now that you know the PLL is indeed working, try the overclocking thing.

    /Henrik.

  14. #14
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    the PIC is specified to run at up to 64MHz so expecting it to run at 80MHz might be a bit of a stretch.
    Pretty much what I raised back in post 2. My part ran at 80 using an external clock+PLL, but that doesn't mean much.

    Ceramic resonator, like crystal oscillators
    You mention that crystal oscillators have logic-level outputs, so I think in your comparison a resonator is closer to a plain crystal (but as you mention they usually include the caps).

  15. #15
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Hi, Peter

    does not your oscillator run or does not your program work as expected ??? Here is THE big question ...

    80 Mhz looks to be "reachable" ( with careful design ... ) with Pics but, as PBP "timed " commands are not available for more than 64Mhz clocking, some commands in your program can't work properly ... ( assembler Ghost in sight !!! )

    sooo, to me, it's no use to go on the " overclocking way " ... without using some assembler.

    Sorry ... Even I do love Hondas ( mine is a 2020 Civic 4D 1.5L CVT ... and I Have Driven only Hondas for ... 32 Years ! )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  16. #16


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I will revisit all the replies. Thanks

  17. #17


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I have the PIC running at 80 and 96mhz on the bench now.
    Looks like it was a setting issue and not waiting for clock to settle before engaging PLL.
    Thanks for the ideas/help.

  18. #18
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    Great.

    Keep us posted on how it goes. I'd be interested to know if you have any problems with peripherals operating at those speeds, esp the builtin CAN controller.

  19. #19


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I also had a bad/fake 20mhz resonator.

    I then tried some Farnell ones and decent crystals all worked ok, even at 96mhz.

    The board actually worked in the car at 96mhz but that is overspec (12mhz) for the 10mhz MCP2515 CAN controllers SPI so I dialled the PIC back to 80mhz for reliability and (10mhz SPI)

    So a decent increase in speed over 64mhz at zero cost so far.

    Now back to the other thread to do some code speed optimisation before I add additional functionality with my extra free time.

  20. #20
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,517


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    I'll admit, I've been sceptical about relying on overclocking for something that is actually being used but I suppose if it works at 96MHz(!) then dialing it back to 80MHz does provide some margin.
    Since it's going to end up in a car I'd probably test it at something other than room temperature before banking on the extra instruction cycles. I know you said it did work in the car at 96MHz but at what temperature?

    Looking forward to the optimisation thread!

  21. #21


    Did you find this post helpful? Yes | No

    Default Re: 18F26K80 Serial setting sanity check and 4xPLL.

    To be fair it worked ok at 64mhz without any optimisation I'm just being greedy and trying to free up/gain some cycles in advance of other stuff.
    I have a heat gun and freeze spray so it's pretty easy to stress it.

    It's been working fine in the summer sun for last two days at 80mhz.
    30-35C in the car.

Similar Threads

  1. Bytes roll over sanity check
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th October 2020, 08:23
  2. Setting RTC by Serial input
    By jamie_s in forum Code Examples
    Replies: 1
    Last Post: - 26th November 2015, 14:57
  3. timer0 10ms setting check
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st July 2015, 11:36
  4. looking for a quick sanity check
    By cncmachineguy in forum Serial
    Replies: 13
    Last Post: - 13th November 2010, 19:53
  5. Block Check on Serial Comms.
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th June 2005, 10:27

Members who have read this thread : 14

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