18F2520 clock speed ?


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23

    Default 18F2520 clock speed ?

    Hello,

    I recently bought a pic/xbee robotic controller board online from www.droids.it . I must say the price was alright and the pcb quality is excellent BUT I just cant figure this one out. It has an 18f2520 with a 10Mhz smt crystal, according to the docs it is actually running at 40Mhz, I assume that has been accomplished by the provided pre-programmed software. So using my awesome U2 programmer, I dumped a simple program to the pic to have it send "hello world" at 9600 baud and receive it on a serial LCD. The exact same setup was used with a 16f873 at 4Mhz and worked great. With the 18f at 10Mhz I only get garbage on the output. So, I then removed the 10Mhz xtal, installed a 4Mhz xtal and it worked. Obviously the pic timing is off when using the 10Mhz xtal, but can I work around this issue in software or is my 4Mhz Xtal the best solution. Heres the program:

    INCLUDE "MODEDEFS.BAS"

    start:

    low porta.4 ' Status LED
    pause 500
    high porta.4

    serout2 portc.6,84,["Hello World...."]

    pause 500
    goto start

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gixxer View Post
    It has an 18f2520 with a 10Mhz smt crystal, according to the docs it is actually running at 40Mhz, I assume that has been accomplished by the provided pre-programmed software.
    Most of the 18F's can multiply the crystal frequency X4, using the Phase Locked Loop feature. So you can run at 40mhz with a 10mhz crystal.

    The options for using the x4 PLL with the HS oscillator are set in the configs.
    This thread explains all that better than I could.

    Presetting Configuration Fuses (PIC Defines) into your Program
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    <br>
    DT

  3. #3
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Hi DT,

    Thanks for that reply. I am able to set all config fuses using the melabs U2 programmer software. I did set the 10mhz xtal to 'HSPLL' under xtal setting, which worked but is also the source of my problem. For example, if I flash an led using a 4mhz xtal at 1hz(1000ms) pause between flashes, it will flash once per second. Using the same program, running at 10 or 40mhz, the led flashes very fast, not at 1hz. This is the problem I'm having with the baud, with 4mhz xtal it all works great and with the 10mhz xtal all I get is garbage at the output. So, obviously 9600 baud at 4mhz is not the same as with a 10mhz xtal. How do I make it output 9600 baud at 10 or even 40mhz ?

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


    Did you find this post helpful? Yes | No

    Default

    PBP assumes you're running at the default 4MHz (regardless what crystal or PLL multiplyer you're using) and bases all it's timings on that unless you tell it otherwise...

    Look for DEFINE OSC in your manual...

    There's also a whole section entitled "How fast is fast enough?" (section 7.1 in my manual).

  5. #5
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Thanks Melanie,

    That explains my problems with any xtal other than 4mhz. I will check into my PBP manual for info about DEFINE OSC, but will that allow the use of other osc frequencies ?
    Also, where do I find your book ?
    And one more thing, are there any threads in this forum already explaining the implementation of Xbee's with pics. I do have mine working @ 4mhz, and they are great, just want more info.

    thanks alot
    John

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gixxer View Post
    Also, where do I find your book ?
    .....................ffffffffffffffffffftttt

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