Setting 8Mhz clock speed on PIC16F684


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562

    Default Setting 8Mhz clock speed on PIC16F684

    Can someone kindly help me please?

    I am trying to make a PIC16F684 run at 8Mhz instead of the default 4Mhz.

    Problem is, test led's just keeping flashing at 10 secs...

    I have MPASM ticked as the Compiler/Assembler and using PBP 2.60

    Simple code below:

    @ __config _INTOSCIO & _WDT_OFF

    DEFINE OSC 8

    OSCCON = %01110000 ' Internal 8MHz osc
    'OSCTUNE = %00000000 ' not in use
    ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
    CMCON0 = %00000111 'Disable analog comparators.
    TRISA = %00000000 'Set PORTA as OUTPUT.
    PORTA = %00000000 'Set PORTA pins all low.


    Start

    main:

    HIGH PORTA.2
    PAUSE 10000
    LOW PORTA.2
    PAUSE 2000
    HIGH PORTA.2
    PAUSE 10000
    LOW PORTA.2
    PAUSE 2000

    goto main
    Last edited by LEDave; - 12th May 2020 at 23:45. Reason: Gramma mistake

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Problem is, test led's just keeping flashing at 10 secs...
    PAUSE 10000 is 10 seconds

    if the osc is 8 mhz and you tell the compiler the osc is 8 mhz with
    DEFINE OSC 8
    then the pause is 10 seconds as requested

    what do you expect the result to be ?
    Last edited by richard; - 13th May 2020 at 00:57.
    Warning I'm not a teacher

  3. #3
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Hi Richard, thanks for the reply.

    "what do you expect the result to be ?"

    I thought (and was hoping) that double the OSC speed from 4 to 8Mhz would drive the led's twice as fast, 10secs would become five at 8Mhz if you see what I mean.

    Dave

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Just to add, I based my last post on this article: http:// melabs.com/resources/pbpmanual/7_0.htm

    But I may have misinterpreted it, in that I thought PAUSE 1000 with DEFINE OSC 4 internal OSC would give one second delay and pause 1000 with DEFINE OSC 8 internal OSC would give 0.5 second delay.....

    So are we saying that the above PAUSE 1000 would both cause a one second delay?

    Is it only external Xtals/resonators that throw the internal timing off?

    Dave

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,379


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Is it only external Xtals/resonators that throw the internal timing off?
    no not at all.

    the only time it fails is when DEFINE OSC does not match the real osc frequency.

    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Thanks again Richard.

    So as long as I use DEFINE OSC X, PB knows and compensates for the change still giving the correct timings PAUSE etc?

    David

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Yes, That is correct. The PAUSE command is based on the OSC frequency. If you had an 4 Mhz. crystal connected and told PBP that the OSC was 8Mhz. the PAUSE command would give you 2 times the value entered into the PAUSE command.
    Dave Purola,
    N8NTA
    EN82fn

  8. #8
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default Re: Setting 8Mhz clock speed on PIC16F684

    Dave & Richard, thank you both for taking the time to reply, much appreciated.

    Dave

Similar Threads

  1. 18F2520 clock speed ?
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 21st August 2008, 20:01
  2. code size VS speed optimization setting?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2008, 15:38
  3. Setting up internal clock correctly?
    By JohnM in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th March 2008, 21:29
  4. Clock Speed
    By Del Tapparo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th November 2007, 03:06
  5. clock speed
    By Armando Herjim in forum General
    Replies: 1
    Last Post: - 30th November 2006, 13:25

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