Internal oscillator please help


+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2009
    Posts
    4

    Default Internal oscillator please help

    I've been trying for a day and a half now to get my PIC to do something I finally have it running but it is running slow. If I put pause 1000 in the code it basically stops. When I do pause 1 it runs at about 4Hz but speeds up if I put my finger near the pic. Whatever changes I make to Internal oscillator speeds it stays at the same speed. It even runs if I set it for external oscillator. I don't understand. Here's the code I have.


    @ Device PWRT_OFF
    @ Device MCLR_OFF
    @ Device INTRC_OSC
    @ Device BOR = 0
    @ Device Debug_Off

    OSCCON = %01110000
    OPTION_REG = %11111111
    TRISB = %00101010



    Any help would be appreciated.

    Thanks,

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,534

    Default

    Which Pic, please ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Dec 2006
    Location
    WADSWORTH OHIO USA
    Posts
    37

    Smile

    RTDS is the answer...

    Refer To Data Sheets
    Last edited by SOMRU; - 25th February 2009 at 20:48. Reason: more
    Thanks !
    SOMRU
    TWE/TFP/EE

  4. #4
    Join Date
    Feb 2009
    Posts
    4

    Default

    Sorry, 16F819

    I've been over the datasheets time and time again and cannot figure this out.

    Thanks

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    It even runs if I set it for external oscillator
    That's a big red flag there. Are you 100% sure you're even programming it?

    If you set config options for an external crystal or resonator, program the part,
    and it's still running, you really do have a problem.

    Post all your code & let us know which programmer you're using. That would really
    help.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Feb 2009
    Posts
    4

    Default

    This is all I have, at this point I was just trying to get the thing to do something in this case the leds on the different ports do switch on and off.

    @ Device PWRT_OFF
    @ Device MCLR_OFF
    @ Device INTRC_OSC
    @ Device BOR = 0
    @ Device Debug_Off

    OSCCON = %01110000
    OPTION_REG = %11111111
    TRISB = %00101010


    loop:

    TRISB = %00101010
    Pause 1
    PortB = 1
    TRISB = %11010101
    Pause 1
    PortB = 1
    TRISB = %00101010
    Pause 1
    goto loop

    End

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Indeed there's a problem, the above don't set the proper config fuses.

    Try
    Code:
    @   device pic16f819, INTRC_OSC_NOCLKOUT
    @   device pic16f819, WDT_OFF
    @   device pic16f819, PWRT_ON
    @   device pic16f819, MCLR_OFF
    @   device pic16f819, BOD_ON
    @   device pic16f819, LVP_OFF
    @   device pic16f819, DEBUG_OFF
    That line you had
    Code:
    @ Device BOR = 0
    screw everything up
    Last edited by mister_e; - 25th February 2009 at 22:40.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    You might want DEFINE OSC 8 in there too if you're running at 8MHz VS the default 4MHz.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9
    Join Date
    Feb 2009
    Posts
    4

    Default

    Well Steve, that seems to have done it Thank You!!! I'm not sure I quite understand it all but I can work it out I'm sure.

    Thanks again.

  10. #10

    Default

    Hi Tim. Maybe this will help you. I believe the following also applys to the 16F88.

    'INTERNAL OSCILLATOR VALUES for 16f818/819:
    'OSCCON = $00 'for 31.25 khz
    'OSCCON = $10 '125khz
    'OSCCON = $20 '250khz
    'OSCCON = $30 '500khz
    'OSCCON = $40 '1mhz
    'OSCCON = $50 '2mhz
    'OSCCON = $60 '4mhz
    'OSCCON = $70 '8mhz
    adcon1 = 7 ' set inputs to digital. Using the adcin command will automatically convert the ADC port to 'analog
    'OPTION_REG.7=0 ' Switch-ON weak pull-up's on portb
    '@ DEVICE MCLR_ON, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON
    'CCPMX_ON THE @ DEVICE LINE ABOVE SETS HPWM OUTPUT TO RB3, CCPMX_OFF (DEFAULT IF NOT 'SPECIFIED) = RB2

Similar Threads

  1. Internal vs. external osc for comms
    By mtripoli in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2010, 15:58
  2. 12F683 internal pull up
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th July 2008, 02:35
  3. PIC18F4620 Using the Internal Oscillator
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2007, 08:07
  4. Use internal program memory like DATA memory
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th December 2006, 19:38
  5. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 22:41

Members who have read this thread : 0

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