PIC18F4620 Using the Internal Oscillator


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    26

    Default PIC18F4620 Using the Internal Oscillator

    Greetings,

    I have been playing around with the PIC18F4620 and have started to pour over the datasheet (daunting task). It says that it has a very good internal oscillator. Up until now I have been using a 4MHz external oscillator as that is what I have done so far and it works. But it seems to me there are big advantages in using the internal oscillator with this chip and running it much faster than 4MHz.

    Has anyone got any good advice on what I should be doing to use the internal oscillator correctly in this chip, or just PIC's generally? Is there any tricks I should be watching out for?

    Also Melanie showed me how to output a Decimal String by putting a # in front of the variable tone i.e. Serout 0, 6, [$1b, $52, 1, #tone]
    Can you output a hex or binary value instead and how do you do this?

    I am using MiroCode Studio and meProg

    Cheers Bruce

  2. #2
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default

    To use the internal oscillator and 4x PLL w/4620/2620 for 32 Mhz you need those defines:

    DEFINE OSC 32
    OSCCON = %11110000 '8 Mhz, internal osc
    OSCTUNE = %11000000 '4x PLL enabled

    You can then use PORT on RA7 and will be able to choose to have clock out or PORT on RA6, by setting the correct config bit. I'm personally setting this with the programmer software (WINPIC from www.qsl.net/dl4yhf).

    J-P

    (BTW this is documented in the datasheet)

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kiwipiper View Post

    Also Melanie showed me how to output a Decimal String by putting a # in front of the variable tone i.e. Serout 0, 6, [$1b, $52, 1, #tone]
    Can you output a hex or binary value instead and how do you do this?

    I am using MiroCode Studio and meProg

    Cheers Bruce
    Hi Bruce,
    I am not sure if this works with serout, but it does with SEROUT2, HSEROUT:
    BIN, HEX, DEC.

    from PBP manual Sec. 5.74 :
    "1) A string constant is output as a literal string of characters.
    2) A numeric value (either a variable or a constant) will send the corresponding ASCII character. Most notably, 13 is carriage return and 10 is line feed.
    3) A numeric value preceded by BIN will send the ASCII representation of its binary value. For example, if B0 = 8, then BIN B0 (or BIN 8) will send "1000".
    4) A numeric value preceded by DEC will send the ASCII representation of its decimal value. For example, if B0 = 123, then DEC B0 (or DEC 123) will send "123".
    5) A numeric value preceded by HEX will send the ASCII representation of its hexadecimal value. For example, if B0 = 254, then HEX B0 (or HEX 254) will send "FE".
    6) REP followed by a character and count will repeat the character, count time. For example, REP A0"\4 will send "0000".
    7) STR followed by a byte array variable and optional count will send a string of characters. The string length is determined by the count or when a 0 character is encountered in the string.

    BIN, DEC, and HEX may be preceded or followed by several optional parameters. If any of them are preceded by an I (for indicated), the output will be preceded by either a "%" , "#" , or "$" to indicate the following value is binary, decimal, or hexadecimal."

    http://www.melabs.com/resources/pbpmanual/
    JS
    Last edited by Archangel; - 23rd October 2007 at 02:33.
    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.

  4. #4
    Join Date
    Oct 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default On Track Again

    Greetings Joe,

    Things are never simple with these PIC's (I suppose that is the challenge). BIN, HEX and DEC do not work with SEROUT you get a compile error. So I have changed to using SEROUT2 instead. A bit of trial and error to get it to use the right baud rate but everything now working again with added features thanks to SEROUT2

    Cheers Bruce

Similar Threads

  1. Pic16f882 internal oscillator
    By offlander in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2009, 21:15
  2. Internal oscillator please help
    By timbash in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th February 2009, 15:11
  3. Internal Oscillator
    By jhorsburgh in forum General
    Replies: 2
    Last Post: - 10th December 2007, 03:13
  4. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 23:41
  5. PIC12F629 w/ Internal Oscillator
    By RossW in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th June 2004, 20:12

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