Setting 8Mhz clock speed on PIC16F684


+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    531

    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 22:45. Reason: Gramma mistake

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,613

    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; - 12th May 2020 at 23:57.
    This is more entertaining than Free to Air TV

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

    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
    531

    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
    1,613

    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.

    This is more entertaining than Free to Air TV

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

    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,152

    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
    531

    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, 19:01
  2. code size VS speed optimization setting?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2008, 14:38
  3. Setting up internal clock correctly?
    By JohnM in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th March 2008, 20:29
  4. Clock Speed
    By Del Tapparo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th November 2007, 02:06
  5. clock speed
    By Armando Herjim in forum General
    Replies: 1
    Last Post: - 30th November 2006, 12:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts