20MHZ External Oscillator Settings


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I did not notice the OSCCON before. It is not needed for your setup.

    The PLL is for anytime you need to run the chip at a different speed than the main OSC. USB is not the only reason.
    The 2550 can be set to run at
    1, 1.33, 2, 4, 16,32, or 48 MHz with a 4 MHz external.

    You will need to DEFINE OSC x to what ever the actual chip speed is if you PLLed it.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I still don't have the 20Mhz XTAL resonating, these are my settings now.
    I have this commented out in the include file:

    Code:
    ;__CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
     ;__CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
    In my program I removed the OSCCON settings.
    I'm setting the HS in my program:

    Code:
     asm
              __CONFIG  _CONFIG1H ,_FOSC_HS_1H 
              __CONFIG  _CONFIG2L ,_BOR_ON_2L & _BORV_2_2L
         
            
        endasm
    I can jumper the 4Mhz XTAL into the circuit and it will resonate, I move the jumpers to the 20Mhz XTAL, I don't get anything.

    I verify with a 200Mhz Fluke scope, and I also have an LCD that gives me a read out. The LCD works with the 4Mhz XTAL jumpered in and I have a nice clean wave form on the scope. The LCD cycles slow and I get garbage sometimes. My guess is that's because I still have the OSC DEFINE 20.

    I though maybe something was up with the 20Mhz XTAL, so I tried another one with some short leads soldered on so it makes a good connection in the breadboard. Second 20Mhz XTAL does't resonate.

    I tried 15, 17 and 20pf caps for the XTAL, no difference.

    So I'm stumped, I do have a question on Mackrackit's Post, saying it can run at:
    "1, 1.33, 2, 4, 16,32, or 48 MHz with a 4 MHz external"

    It looks like all the settings divide the external XTAL speed, I don't see how I would get 16 or 32Mhz? If I can get 16 or 32Mhz with my 4Mhz XTAL I may have enough speed. At least it's worth a try.

    Thanks, Let me know where I'm going wrong.
    Shane

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I do not use crystals so I can not comment on that.
    Here are the configs to run at 48 MHz with a 4 MHz resonator.
    Code:
    DEFINE OSC 48
        @ __CONFIG   _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        @ __CONFIG   _CONFIG1H, _FOSC_HSPLL_HS_1H
        @ __CONFIG   _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
        @ __CONFIG   _CONFIG2L, _PWRT_ON_2L & _VREGEN_ON_2L
        @ __CONFIG   _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
        @ __CONFIG   _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Apr 2009
    Location
    Boise, Id
    Posts
    44


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    Thanks for the settings, that allowed me to follow the table in the data sheet and make sence of the settings in the .inc files. This is what I have figured out so far:

    I can use DEFINE OSC for 4, 16 and 20Mhz. Anything else I get a compile error, " Integer not previously defined.."

    So I used the old reliable 4Mhz XTAL and configured for 16Mhz CPU instead of the 48Mhz in Mackrackit's reply. That worked, but then my DT timer was running at about 1/4 speed. If I put Define OSC back to 4, my timing was fixed.

    Did a few more tests and found that I could set the configs to 48, 32,24 or16Mhz, the number of A/D conversions seems to be the same. I always seem to need the Define OSC 4.


    Next, was to get the 20Mhz XTAL working, using what I learned from the last 2 hours of testing, I was sure I could plug the 20Mhz in and be set to get back to coding. Nope-not that lucky!

    After more time I got it working, then I connected the scope and it stopped working. Seems that connecting the scope to the 20Mhz signal destroys it, don't know if its the extra capacitance from the probes?

    The tool that was supposed to help me figure out why I wasn't resonating was causing the issue...go figure.

    I also timed the execution speed (number of A/D conversions per second) for different cpu speeds, they all seem the same ( 48, 32 24 and 16Mhz). I left the DEFINE OSC 20 and the DT timer looks spot on.

    Seems that the (CPUDIV1:CPUDIV0) must only affect the USB speed? At least for this model of PIC?

    Here is what I ended up with:

    Code:
    __CONFIG  _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
     __CONFIG  _CONFIG1H, _FOSC_HSPLL_HS_1H
    And it's working, although I'm still confused on the execution speed not changing when changing the (CPUDIV1:CPUDIV0) settings?

    Thanks for your help, let me know if you have any advice regarding my current confusion.

    Shane

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I am not sure if measuring the ADC time is the best test. There are other things that effect the ADC speed.

    You might try setting up an LED to blink at 1 Hz then test.

    The settings are for the MCU speed, not just USB.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I guess that no one reads my posts. I have mentioned numerous time that you can do a superb job of measuring your PICS actual speed by
    using a routine such as:

    DEFINE OSC X

    LEDON

    For X = 1 to 60
    PAUSE 60000
    Next X

    LED OFF

    Of course, you don't have to time for a full hour, but the accuracy gets better the longer you wait.
    If have

    If you use DEFINE OSC 20 and the LED stays on for 31 minutes, you are actually running at

    (60/31) * 20MHz = 38.7096Mhz.

    Just make sure you don't have interrupts running when you do the timing.
    Charles Linquist

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    charles I read them with great intrest!!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

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