18F25K20 osc / clock odd frequency


+ Reply to Thread
Results 1 to 11 of 11

Thread: 18F25K20 osc / clock odd frequency296 days old

  1. #1
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default 18F25K20 osc / clock odd frequency

    Hi, I am trying to use the 18F25K20 for the first time in a project and have run into a new (to me) problem , have both 16 MHz & 64 MHz crystals and 16 MHz resonators, the project wouldn't run at fist, giving odd characters on the 2 line LCD on default port B. I changed from 16 MHz crystal to 64 MHz crystal and it started working, only after some timing problems did I check the oscillator frequency with a scope and found it running at 21 MHz, I checked the crystal resonance and it is correct, I suspect I have something wrong in the config, but am lost as to what, I tried using the fuse configurator MK2 utility kindly provided by Johngb , but no matter what options I set I get either nothing (no oscillator) or 21MHz. I tried 22pF and then 6pF caps, no good.
    Are there special requirements for running a 64 MHz crystal, I read the data sheet and it doesnt seem to specify anything different from what I have tried.
    Has anyone else had this issue or can point me in the right direction? I have been on this for a couple of days and running out of ideas.

    Thanks.

  2. 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. #2
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,966
    Thumbs Up
    Received: 96
    Given: 34
    Total Downloaded
    5.15 GB

    1 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Without checking the data sheet I'm unsure whether the device will run an external 64MHz crystal.
    I suggest you use a 16MHz crystal and the 4x PLL fuse.
    Use Fuse Configurator for setting this up.
    Then, and here's the confusing bit, in the program you set Xtal= 64

    The last mentioned just tells the compiler to calculate all its timings based on a 64MHz clock.
    When I get to my computer I'll look up the fuse settings for you.
    Cheers
    John

  4. 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. #3
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Thanks for that John, I have tried the 16MHz resonator and can only get it to run the oscillator by declaring it as a 16MHz crystal, when I try to use the configurator, the oscillator stops running, no matter which option I set LP, XT, HS or HSPLL. I tried
    HSPLL and XTAL = 64, no clock runs, I am going over the circuit again (and again :P )looking for hardware issues.
    Thanks

  6. 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. #4
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    By accident I just tried the one thing I hadn't tried, using a 16MHz resonator and XTAL = 64 ,no other config settings, works - timing all spot on, clock is running at 16 MHz. Not sure if there will be other issues if I leave it this way, but so far everything seems to be working OK.
    Thanks

  8. 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. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,701
    Thumbs Up
    Received: 361
    Given: 173
    Total Downloaded
    2.08 GB

    1 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Unfortunately that is my fault. :-( I enabled PLL by default for the 18F25K20 because it was the microcontroller used in the Amicus18 and I wanted to make it much easier for the Amicus18 user, but that was a failed venture. :-(

    I'll be moving it back to standard HS configs in the next update of the compiler, but for now, use the Configs shown below to make the oscillator run without the 4xPLL setting. This will give you 16MHz for your 16MHz crystal, but you are actually much better off keeping it at 64MHz because it is so much faster and smoother:

    Code:
        Device = 18F25K20
        Declare Xtal = 16
        
        Declare Hserial_Baud = 19200
        Declare HRSOut_Pin = PORTC.6
        Declare HRSIn_Pin = PORTC.7
          
    '-------------------------------------------------------------------------------
    ' Setup the config fuses for external oscillator with no PLL
    '
    Config_Start
        FOSC = HS           ' HS oscillator, PLL disabled
        Debug = Off         ' Background debugger disabled' RB6 and RB7 configured as general purpose I/O pins
        XINST = Off         ' Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        STVREN = Off        ' Reset on stack overflow/underflow disabled
        WDTEN = Off         ' WDT disabled (control is placed on SWDTEN bit)
        FCMEN = Off         ' Fail-Safe Clock Monitor disabled    
        IESO = Off          ' Two-Speed Start-up disabled
        WDTPS = 128         ' Watchdog is 1:128
        BOREN = Off         ' Brown-out Reset disabled in hardware and software
        BORV = 18           ' VBOR set to 1.8 V nominal
        MCLRE = On          ' MCLR pin enabled, RE3 input pin disabled
        HFOFST = Off        ' The system clock is held Off until the HF-INTOSC is stable.
        LPT1OSC = Off       ' T1 operates in standard power mode
        PBADEN = Off        ' PORTB<4:0> pins are configured as digital I/O on Reset
        CCP2MX = PORTC      ' CCP2 input/output is multiplexed with RC1
        LVP = Off           ' Single-Supply ICSP disabled
        Cp0 = Off           ' Block 0 (000800-001FFFh) not code-protected
        CP1 = Off           ' Block 1 (002000-003FFFh) not code-protected
        CPB = Off           ' Boot block (000000-0007FFh) not code-protected
        CPD = Off           ' Data eeprom not code-protected
        WRT0 = Off          ' Block 0 (000800-001FFFh) not write-protected
        WRT1 = Off          ' Block 1 (002000-003FFFh) not write-protected
        WRTB = Off          ' Boot block (000000-0007FFh) not write-protected
        WRTC = Off          ' Configuration registers (300000-3000FFh) not write-protected
        WRTD = Off          ' Data eeprom not write-protected
        EBTR0 = Off         ' Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
        EBTR1 = Off         ' Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
        EBTRB = Off         ' Boot block (000000-0007FFh) not protected from table reads executed in other blocks
    Config_End 
    If you want 4xPLL, change the config line to: FOSC = HSPLL ' HS oscillator, PLL enabled

    Sorry about the confusion caused.

  10. 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. #6
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    No worries, its all working now with no config, but if you will be changing this in future I will have to have another go at getting it to work with a config block.
    when I looked at the Amicus config file for clues I found

    FOSC = HSPLL ' HS oscillator, PLL enabled and under software control

    As I wasn't sure where the " PLL software control " should be controlled from, I just tried a 64MHz crystal in and it had seemed to work (albeit with some odd timing issues that I coded around before realising the osc was running at 21MHz).

    in your posted example config, would I need to still set xtal = 64 and then fosc = hspll ?

    Thanks for our time

  12. 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. #7
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    557
    Thumbs Up
    Received: 33
    Given: 7
    Total Downloaded
    3.87 GB

    1 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Quote Originally Posted by brett View Post
    FOSC = HSPLL ' HS oscillator, PLL enabled and under software control

    As I wasn't sure where the " PLL software control " should be controlled from, I just tried a 64MHz crystal in and it had seemed to work (albeit with some odd timing issues that I coded around before realising the osc was running at 21MHz).
    I have not checked the datasheet but from memory I think you need to set a (OSCCON?) register bit to enable the PLL, hence it is done in your code and thus "software enabled/controlled". That is probably the case wherever you have a device with a PLL and no PLL config fuse.
    Using PLLs can be a bit complicated due to the different ways you can set them up and inform the complier of XTAL frequency, you may find reading this of some use. It is a few years old now but I think it is still applicable.

  14. 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.

  15. #8
    Prolific Poster John Drew's Avatar
    Join Date
    Feb 2002
    Posts
    2,966
    Thumbs Up
    Received: 96
    Given: 34
    Total Downloaded
    5.15 GB

    2 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    G'day Brett,
    To solve the 21MHz mystery. Higher frequency crystals operate in overtone mode. They operate in odd multiples of their fundamental frequency. So it would seem that your crystal is a 21.3333MHz crystal meant to oscillate on its third overtone. Instead the circuit in the PIC18Fxxxx only allows for fundamental crystals. Overtone crystals are cut in specific ways to encourage overtone operation but only in the correct circuit. If the crystal operates in fundamental mode its frequency is not exactly 1/3 or 1/5 or 1/7 of its marked value.
    Overtone operation is not harmonic operation.
    Hope this explains your "funny" operation.
    Cheers
    John

  16. 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.

  17. #9
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Thanks again for the input John, that makes sense with what I am seeing. I should correct my previous post, without any config block, using a 16MHz resonator and just declaring the xtal = 64, the clock is running at 64 MHz and the oscillator is running at 16 MHz.
    Thanks to everyone for your replies, all appreciated.

  18. 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.

  19. #10
    Junior Member brett's Avatar
    Join Date
    Jul 2008
    Posts
    19
    Thumbs Up
    Received: 1
    Given: 4
    Total Downloaded
    691.82 MB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    The linked article is very helpful, my first time using such a high speed clock, so had not seen this issue before.
    Thanks

  20. 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.

  21. #11
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,374
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: 18F25K20 osc / clock odd frequency

    Moral of the story, don't trust to defaults you don't understand, explicitly state fuses, I2C hardware pins etc. etc. It make code much more comprehensible.

    BTW You can put fuses anywhere in you source file.I always put mine ate the very end, out of the way.
    George.

  22. 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. Trying to run a 18f25k20 internally
    By jamachine in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 21st April 2016, 02:09
  2. Serial communication between 2 18f25k20
    By Pic in forum Projects discussion
    Replies: 4
    Last Post: 4th July 2015, 00:06
  3. [SOLVED !] how to disable processor clock frequency in proteus
    By s4cnc in forum Labcenter Proteus VSM
    Replies: 3
    Last Post: 5th April 2009, 13:30
  4. [SOLVED !] VSM 16F877 clock frequency
    By Alan in forum Labcenter Proteus VSM
    Replies: 7
    Last Post: 26th February 2006, 08:04
  5. Replies: 11
    Last Post: 30th November 2005, 16:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts