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

  2. #2
    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

  3. #3
    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!

  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 speed test, I'll give it a try and post my results.

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


    Did you find this post helpful? Yes | No

    Default Re: 20MHZ External Oscillator Settings

    I tried the speed test to check code execution time at 24Mhz and 48Mhz. I left the DEFINE OSC 20 for both tests. I used pause loops like Charles suggested, and used 10 minute long tests. I know longer would be better, but I think 10 minutes should show any difference. Both times the LED was on for 10 minutes, the best I could measure with a clock second hand.


    I only changed the _CONFIG1L setting "_CPUDIV_OSC1_PLL2_1L" and _CPUDIV_OSC3_PLL4_1L between the tests. So I'm still scratching my head, seems if the CPU was running at 48Mhz but my define is at 20Mhz, it should have taken 4.1 minutes. So it seems the clock speed for code execution is derived directly from the external XTAL?

    My A/D sampling frequency is now fast enough for my needs, as long as I keep the rest of my code in check I should be OK. I'd still like to understand why this is happening (or not happening)???
    Thanks
    Shane

    Here is the code I used:

    Code:
                       '_CPUDIV_OSC1_PLL2_1L '48 Mhz
                        '_CPUDIV_OSC3_PLL4_1L '24 Mhz
                        
    DEFINE LOADER_USED 1
     asm
              __CONFIG  _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
              __CONFIG  _CONFIG1H, _FOSC_HSPLL_HS_1H
              __CONFIG  _CONFIG2L ,_BOR_ON_2L & _BORV_2_2L
         
            
        endasm
        
     DEFINE OSC 20
     
    X VAR  Byte    
      
    TRISC.0 = 0          
              
    Portc.0 = 0
     
    For X = 1 to 10   'Turn LED on for 10 min
     PAUSE 60000
     Next X
     
     Start:
     Portc.0 = 1        'Start Toggling LED
     For X = 1 to 10
     PAUSE 100
     Next X
     Portc.0 = 0
     For X=1 to 10
    Pause 100
    Next X
    Goto START

  6. #6
    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

    Dave
    Always wear safety glasses while programming.

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