18F1320 question


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2010
    Posts
    409

    Default 18F1320 question

    I'm using an 18F1320 with it's internal oscillator. I've got a basic blink program running, but the clock seems to be running very slowly and nothing I change in the OSCCON register changes the clock. Is there something in the config registers or somewhere else I'm missing that overrides the values in OSCCON? 2 Hours of reading and experimenting is getting hard on my hair - thanks for any clues!

  2. #2
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    What do you have your OSCCON set at?
    The main output is an 8MHZ clock which can be varied from 125kHz to 4MHz via the postscaler.
    Have you defined the clock speed in your program to match that set by OSCCON?
    Example: if you have the INTOSC set at 8MHZ then you should include the define

    DEFINE OSC 8

    at the beginning of your program.

    To help more we would need to see your actual code to help debug the problem.

    Cheers
    Barry
    VK2XBP

  3. #3
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    Thanks, Barry. If you read what I originally posted you will see that you can set OSCCON to any postscaler value and the behaviour does not change.
    And yes, I read the documentation - I know how it is supposed to work.

    The actual code is not going to help this time, but sure:

    OSCCON = $11110011
    DEFINE OSC 8
    CLEAR
    ADCON1 = 0
    Startup:
    TRISA = 0
    PORTA.1 = 1
    pause 10
    PORTA.1 = 0
    pause 10
    goto startup
    end

    The LED on PORTA.1 is blinking just slightly faster than once per second, when it should be so fast you don't even see it blinking.

    So to repeat the original question: Is there something in the config registers or somewhere else I'm missing that overrides the values in OSCCON?

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


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    I have one question. Why are you setting the TRIS register each time thru the loop?
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    Try changing your OSCCON statement to:

    OSCCON = %11110011

    Cheers
    Barry
    VK2XBP

  6. #6
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    I'm totally embarrassed. Snookered by a typo. Thanks, Barry.

  7. #7
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    I guess the "actual code" was able to help after all...

    Cheers
    Barry
    VK2XBP

  8. #8
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    Official chastising accepted - please pass the crow.

  9. #9
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: 18F1320 question

    Hahaha - Sorry, couldn't help myself...
    All good

    Cheers
    Barry
    VK2XBP

Similar Threads

  1. Another 18F1320 ICD confusion
    By Ramius in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th April 2012, 19:04
  2. 18f1320 icd
    By Ramius in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th April 2012, 14:00
  3. 18F1320 And I/0
    By johnyman34 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th December 2006, 20:19
  4. How to define it, in 18F1320?
    By johnyman34 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th November 2006, 19:01
  5. 18F1320 ... Strange Memory
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 9th April 2006, 09:55

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