18F2520 clock speed ?


Closed Thread
Results 1 to 25 of 25
  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

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


    Did you find this post helpful? Yes | No

    Default

    Close Ski - but no cigar...

    The correct answer is "It was in the bottom of the box when you bought your software".

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Close Ski - but no cigar...
    The correct answer is "It was in the bottom of the box when you bought your software".
    Aw....shucks! I knew I should've taken Door #2.
    Could I get a consolation prize on my way out the door?
    (somebody else around here did say I've been 'off' for the past couple of weeks or something)

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


    Did you find this post helpful? Yes | No

    Wink

    hmm...

    skimask, what does " .....................ffffffffffffffffffftttt" mean ?

    As for this manual/book at the bottom of my box, I'll let you know if I ever find that. It's probably still packed as I moved recently.

    Back to my last post, do I simply define osc 10 or 40, or is ther more to it ?

    thank you

  10. #10
    Join Date
    May 2008
    Location
    Florida
    Posts
    64


    Did you find this post helpful? Yes | No

    Default

    Melanie you don't keep it under your pillow?
    I laugh but at times I kind of wonder if just maybe you did write the book.



    skimask, what does " .....................ffffffffffffffffffftttt" mean ?


    Sound beer makes hitting keyboard or monitor!
    Last edited by manwolf; - 16th August 2008 at 00:29.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by manwolf View Post
    Melanie you don't keep it under your pillow?
    I laugh but at times I kind of wonder if just maybe you did write the book.
    skimask, what does " .....................ffffffffffffffffffftttt" mean ?
    Sound beer makes hitting keyboard or monitor!
    Steam escaping...
    A big ol' electrolytic capacitor relieving it's self one last time in a puff of smoke...

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


    Did you find this post helpful? Yes | No

    Default

    Actually, my old Robosapien walked off with what I had under my pillow (you'll have to do a forum search for that thread) some time back, and I've not seen him or it since... however I think he's earning a good living somewhere as the girls in the neighbourhood seem to always have smiles on their faces...

  13. #13
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Actually, my old Robosapien walked off with what I had under my pillow (you'll have to do a forum search for that thread) some time back, and I've not seen him or it since... however I think he's earning a good living somewhere as the girls in the neighborhood seem to always have smiles on their faces...
    Hmmmph, Powertools, whoa ho ho ho
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Talking

    ...........zzzzzzzzzzz

    wow, thank you Sooo much for such useless information....

    John

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


    Did you find this post helpful? Yes | No

    Default

    John

    Get up off your butt and do a forum search for DEFINE OSC (a secret phrase known only to everyone that programs with MeLabs PICBASIC who happens to have read the product manual) that I mentioned back in post number #4 in this thread. Not got the manual? Then go onto the manufacturers website (this forum has got a dozen pointers to it) where you can locate the product manual and look up DEFINE OSC. You do remember who makes your compiler don't you? No? (there's a highlighted clue in this paragraph and Google comes free with every internet connection). In case you missed it - DEFINE OSC is the answer to your problem. Once you've got the manual, go look in the section I pointed you to (again back in Post #4). Don't say that you've had "useless information" when you were told the answer a few hours after posting your question.

    Geeze, teach a guy to fish and he'll spend all day in a boat with a crate of beer.

  16. #16
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post

    Geeze, teach a guy to fish and he'll spend all day in a boat with a crate of beer.
    That's why I'm learnin' to fish
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Talking

    MEL,

    Your right, you did explain in post #4 that using DEFINE OSC was needed to adjust all required timings. You then said "There's also a whole section entitled "How fast is fast enough?" (section 7.1 in my manual). "
    To which I asked "where do I find your book ?"

    How the hell should I know that you have some connection to Melabs.
    Honestly, I don't really care who you are affiliated with, I was just trying to get this circuit working. As it turns out, the board is fully functional and has been since the first post, I had already figured out that it would work with a 4Mhz xtal.
    I did try the define osc before my first post, I had deleted it from my code because it didn't work. That is what lead to Post #3, which I described how the xtal fuse settings vastly affected the timing, again looking for a constructive reply !

    Thanks

  18. #18
    Join Date
    May 2008
    Location
    Florida
    Posts
    64


    Did you find this post helpful? Yes | No

    Default

    "where do I find your book ?" = Melanie's manual
    Melanie's manual = MicroEngineering Labs, Inc. PICBASIC PROtm Compilier manual



    In my copy

    Section 7.1 is on page 171, look down the page about 3/4 of the ways. Sentence begins "However..."


    You should be able to find the answers to your questions there.

    The PBP Manual is also known as: the Manual, the ugly green book, the bible, etc. around these parts.

    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 ?
    If you had checked the PBP manual you would not have asked that question or needed to for that matter.
    Last edited by manwolf; - 21st August 2008 at 01:50.

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


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Yes I had cheched the manual, just didn't know or cared who wrote it. I don't run and post a question here or anywhere unless I just can't figure something out. I will read anything I can get my hands on, online or otherwise, until I find the solution. Granted, I'm no expert, so this process can take some time, but usually I will succeed. I DID refer to the manual, don't need a forum to tell me to look there first. As I said, I had also ALREADY tried using DEFINE OSC 10Mhz, it did not work. The output baud timing was way off. I also wasn't sure about what config fuses to set with the U2 programmer regarding the xtal. The original crystal is a SMT type, 10 Mhz. I tried all different fuse settings, which of course affected the timing, but none gave the proper result at the pic output. So I installed a SMT 4Mhz xtal and, you guessed it-works great.

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


    Did you find this post helpful? Yes | No

    Wink

    one more thing....

    "where do I find your book ?" = Melanie's manual
    Melanie's manual = MicroEngineering Labs, Inc. PICBASIC PROtm Compilier manual
    .....ok, thanks for that manwolf...

    And from Mel's profile,
    "Occupation:
    I DO NOT work for MeLabs or Crownhill. Both those companies however continue to get my vote. "
    Now I am curious, did you write this manual, or is that an urban legend 'around these parts'.
    ?
    your PBP pal,

    John

  21. #21
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gixxer View Post
    one more thing....
    "where do I find your book ?" = Melanie's manual
    Melanie's manual = MicroEngineering Labs, Inc. PICBASIC PROtm Compilier manual
    .....ok, thanks for that manwolf...
    And from Mel's profile,
    "Occupation:
    I DO NOT work for MeLabs or Crownhill. Both those companies however continue to get my vote. "
    Now I am curious, did you write this manual, or is that an urban legend 'around these parts'.
    ?
    your PBP pal,
    John
    Melanie's manual <> PicBasicPro Compiler manual...however...
    Melanie's REFERENCE manual used way back when Melanie didn't know anything about PicBasicPro may have been the PicBasicPro Compiler manual, written by microEngineering Labs, Inc (at least that's what I've assumed all along). Can't remember the name of the person(s) that are responsible for the upkeep/updating of the core of PicBasicPro itself off hand though...

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


    Did you find this post helpful? Yes | No

    Talking

    LOL, all I wanted to do was avoid desoldering the original 10mhz SMT xtal with a 4mhz, but the desoldering took far less effort.
    Thanks to all that replied anyhow.

    John

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


    Did you find this post helpful? Yes | No

    Default

    I had also ALREADY tried using DEFINE OSC 10Mhz, it did not work.
    That's because DEFINE OSC 10Mhz is the wrong syntax.

    I didn't write the book - That's urban legend! (but I have seen it once in a previous life). I have never used the paper copy, because I downloaded the pdf and it's a hell of a lot easier to use the Adobe FIND feature to locate exactly what I'm looking for, rather than waste time thumbing through a hundred pages.

    And if people can't figure where to download the pdf... then takeup landscape gardening for a hobby!

    And finally John, the reason folks are reluctant to help when you haven't got a manual, is it usually applies to someone that has not acquired a legal copy (since the manual comes free with the product).

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


    Did you find this post helpful? Yes | No

    Default

    Hey Mel,

    If you or others are "reluctant to help when you haven't got a manual" ...because..."it usually applies to someone that has not acquired a legal copy (since the manual comes free with the product).", then thats fine by me. If you happened to read post 9 you would see that I stated I recently moved, which translates in english to I can't locate my PBP book that came with the software. Thats the "book" you told me to look in. What do you do, test people to see if they possess this stupid book ? I too, since my PURCHASE of PBP for $249.95, also use the pdf AND my printed copy of the manual. I also PURCHASED the MELABS U2 programmer as already stated, or do ya think I "acquired" that illegally too(downloading of matter-maybe there is a pbp command for that!). My only mistake in all of this was basically a typo that you pointed out-DEFINE OSC 10Mhz, which was how I typed it in my post because I was tired. However, in my program I did enter it minus the Mhz--it did not work. I don't know why it didn't work, but the timing was still off. Go figure, thats why I posted my question in the first place. The couple of posts I made in the past which were promptly and maturely answered by "Mister E", was how I thought it worked around here-not having someone call you a thief.......geeez !

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


    Did you find this post helpful? Yes | No

    Default

    I wasn't accusing you personally of anything. I did however reflect on the attitude of a large number of contributors to this forum.

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

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