PIC18s and Oscillator settings


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    Well it sure appears your pic is configured correctly, I think. Do you have OSC in your code? what version of PBP are you using? I remember something about OSC messing with something in some of the 18's when using 2.6C, but don't know the fix or if it applies to the pic you are using, But there is a fix if thats what it is.

    So do you think the pic is running at 32?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    I removed the DEFINE OSC so that the software thinks it is running at 4 MHz (default), but it is really running at 32MHz based on the OSCCON and OSCTUNE register settings. I think that it is actually running at this speed because my pc based interface program is set to a baud rate of 38400. So if my pic is running 8 times faster than the code thinks it is then I should set my serin2 to 4800 (38400/8=4800). Now the two will communicate correctly. However, if you noticed in the code where I have the following:
    trigger1=1
    trigger2=1
    pauseus 1
    trigger1=0
    trigger2=0
    When I measure the time that the triggers are actually on I am seeing about 12.6 microseconds. Looking in the pbp manual under the PAUSEUS command, I was expecting to see a pulse of about 2 usec. Not sure how long the instruction to change the state of a pin takes, but it seem like I should have better resoultion at 32 MHz.
    Thoughts?

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    http://melabs.com/support/patches.htm#pbp
    Has a patch fixing baud rate accuracy for SERIN/SEROUT commands. Not sure if it will help here.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    I'm not familiar with the 18F4515, but this line looks odd to me...

    Code:
    @ CONFIG OSC = INTIO67 ;config for internal osc
    INTIO67 ??

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    From P18F4515.inc
    ;----- CONFIG1H Options --------------------------------------------------
    _OSC_LP_1H EQU H'F0' ; LP oscillator
    _OSC_XT_1H EQU H'F1' ; XT oscillator
    _OSC_HS_1H EQU H'F2' ; HS oscillator
    _OSC_RC_1H EQU H'F3' ; External RC oscillator, CLKO function on RA6
    _OSC_EC_1H EQU H'F4' ; EC oscillator, CLKO function on RA6
    _OSC_ECIO6_1H EQU H'F5' ; EC oscillator, port function on RA6
    _OSC_HSPLL_1H EQU H'F6' ; HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
    _OSC_RCIO6_1H EQU H'F7' ; External RC oscillator, port function on RA6
    _OSC_INTIO67_1H EQU H'F8' ; Internal oscillator block, port function on RA6 and RA7
    _OSC_INTIO7_1H EQU H'F9' ; Internal oscillator block, CLKO function on RA6, port function on RA7
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2010
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: PIC18s and Oscillator settings

    So that anyone who may also be having this problem, I am posting the fix (Provided by Mr. Darrel Taylor -- Thanks):

    "With older versions of PicBasic Pro, you should not use the CONFIG (no underscores) directive in your code.
    You can with PBP3, but it looks like you haven’t upgraded yet.

    The 18F4515 uses the older __CONFIG directives.
    Look in the P18F4515.inc file in the c:\program files\microchip\mpasm suite folder for the available options.
    But I think you want …

    ASM
    __CONFIG _CONFIG1H, _OSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_OFF_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H
    __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    ENDASM"

    I changed to the old config directives and 1: it compiled correctly and 2: it works! For the record PBP 2.60A is the version I am using.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

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