How to verify HS_PLL clock speed


Closed Thread
Results 1 to 18 of 18
  1. #1

    Default How to verify HS_PLL clock speed

    Is there an easy way to check the clock if it is multiplied using the PLL? I want to confirm that I'm running at 16MHz (4MHz x 4). Will the OSC2 output a 16MHz signal?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    What PIC are you using?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I'm using the 18F452 running at 4MHz.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The easiest way I know to check would be with an LED & a few pause statements. If HSPLL isn't running it will be obvious on the LED.

    Main:
    HIGH LED
    PAUSE 500
    LOW LED
    PASE 500
    GOTO Main

    OSC2 can output the clock/4, but only in EC mode. In other modes, the signal from OSC2 output is so weak you'll load it with a scope probe.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Would this not enable the x4 PLL?

    Code:
    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
    @ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H 
    @ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It should, but check this with your programmer before programing that part.

    Also, you might want to use the osc resistor shown in the datasheet since this may be over driving your crystal. HS uses a higher drive output on OSC2.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7


    Did you find this post helpful? Yes | No

    Default

    I'm actually using a TTL oscillator so this shouldn't be an issues should it?

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    "EDIT"

    For OSC2 to output clock/4 with a TTL clock oscillator, you'll need to use EC or ECIO mode.

    HSPLL isn't available for EC or ECIO mode. With a 4MHz TTL clock oscillator, you'll have only 4MHz. HSPLL mode works with the TTL clock if you set config fuses for HSPLL, but you can't use the OSC2 pin in HS mode. Only EC or ECIO modes.
    Last edited by Bruce; - 22nd August 2005 at 19:56.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9


    Did you find this post helpful? Yes | No

    Default

    ah, I'll drop in a crystal then, I have both at my disposable.

  10. #10
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You know, it's not really 100% clear from the datasheet, but looking at Figure 2-2, it does appear an external clock, I.E. a TTL osc can be input to OSC1, and you can select HS, XT or LP modes, so it "appears" you can use a TTL clock in on OSC1, and still make use of the HSPLL as long as you have HS set in config.

    I'll have to experiment with that one.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Just wanted to add that the PLL only starts up properly on Power-Up.

    The first time you program a chip with the PLL turned on, it won't actually start working at x4 untill you turn the power off and on again. A simple reset of MCLR wont do it.

    <br>
    DT

  12. #12
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    And it "does" work with a 4MHz TTL clock input with HSPLL set. Just tested it. __CONFIG _CONFIG1H,_OSCS_OFF_1H & _HSPLL_OSC_1H

    You just can't use the OSC2 pin for I/O or clock/4 output without using EC or ECIO mode.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  13. #13


    Did you find this post helpful? Yes | No

    Default

    On that note then, using this code it should run at 16MHz internally, correct?

    Code:
    @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
    @ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
    @ __CONFIG _CONFIG2H, _WDT_ON_2H 
    @ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
    
    Main:
    HIGH portd.1
    PAUSE 500
    LOW portd.1
    PAUSE 500
    GOTO Main
    This reminds me of the old 486DX2 and DX4 microprocessors

  14. #14
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I'm using MPASM version 4.02 which complains if I use the old __config options, so I replaced the old options in the .inc file with:
    CONFIG OSC=HSPLL,OSCS=OFF,LVP=OFF,PWRT=ON,BOR=ON,WDT=OFF, BORV=25,WDTPS=128,CCP2MUX=OFF,STVR=OFF

    DEFINE OSC 16

    LOOP:
    HIGH 0
    PAUSE 500
    LOW 0
    PAUSE 500
    GOTO LOOP

    With the 4MHz TTL input to OSC1, it produces .5 S pulses on RB0. So assuming your programmer isn't altering config fuse settings, and you're getting it programmed with HSPLL, then it should definitely be running at 16MHz internally.
    Last edited by Bruce; - 22nd August 2005 at 20:37.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  15. #15


    Did you find this post helpful? Yes | No

    Default

    I added the DEFINE OSC 16 and it only flashes about once every 2 seconds. I have cycled power and still the same thing.

  16. #16
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    If you're programming in-circuit, did you cycle power?

    As Darrel mentioned previously, you need to cycle power OFF then back ON when switching to HSPLL mode.

    With DEFINE OSC 16 -- a 2 second pause is what you'll see if the PLL isn't locked in. It's running directly from the 4MHz TTL clock input until the PLL circuit locks-in, and kicks in the 4x PLL.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  17. #17


    Did you find this post helpful? Yes | No

    Default

    I think I just found my problem. The bootloader doesn't seem to be changing the configuration bits properly. I programmed the PIC in the EPIC programmer and it works fine now. Thanks for the help. I'll look further into the other programming method tomorrow.

  18. #18


    Did you find this post helpful? Yes | No

    Default Source of Problem Found

    Just discovered the source to my misery. According to the help file that comes with the bootloader, "The microcontroller ID location and configuration fuses are not available to the loader process. Configuration fuses must therefore be set at the time the bootloader software is programmed into the target microcontroller."

    This would explain my problems. Like the expression goes, RTFM

Similar Threads

  1. Clock Speed
    By Del Tapparo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th November 2007, 02:06
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. clock speed
    By Armando Herjim in forum General
    Replies: 1
    Last Post: - 30th November 2006, 12:25
  5. Faster Clock Speed for Shiftin/out?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2005, 02:15

Members who have read this thread : 1

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