How to set 18F2520 for INT OSC?


Closed Thread
Results 1 to 15 of 15
  1. #1
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156

    Default How to set 18F2520 for INT OSC?

    How in the world do you set a 18F2520 to use it's INTERNAL oscillator @ 8 MHz? I've got
    OSCCON set like this

    OSCCON = %01110010

    but still not running. On the melabs serial programmer, the only INTernal osc settings are INTRC (INTIO1), and INTRC (INTIO2). Are those correct?

    Very confused.

  2. #2
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I guess it is oscillating, but it takes 25 seconds to start! I assume that has to do with the delay timers.

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


    Did you find this post helpful? Yes | No

    Default

    Give up try to set the fuses with the programmers software and set them in the *.inc file or code space
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Then as the above link explains, goto the MPASM Suite directory and look at the P18F2520.INC file.
    At the end of the file you will find all of the settings. You want
    _OSC_INTIO67_1H
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    Thanks Dave.

  5. #5
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I have to use an external oscillator after all, because the internal is just not stable enough. I've got everything configured correctly (I think), but the first thing the program does, is turn on a LED. It's taking 25 SECONDS for this LED to come on!!

    I've checked the datasheet, and power-on delays can be because of PWRTEN being set to 0, (which it isn't), or OST, but that isn't suppose to apply with external oscillators. So... what could be the problem?

    My PBP 18F2520.INC file is below.

    Code:
    ;****************************************************************
    ;*  18F2520.INC                                                 *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2010 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 05/21/10                                        *
    ;*  Version   : 2.60a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F2520, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F2520.INC"   ; MPASM  Header
            __CONFIG    _CONFIG1H, _OSC_ECIO6_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2L, _PWRT_OFF_2L & _BOREN_ON_2L & _BORV_0_2L
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_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
            NOLIST
        endif
            LIST
    EEPROM_START	EQU	0F00000h
    BLOCK_SIZE	EQU	32
    Thanks for any pointers.

    Len

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


    Did you find this post helpful? Yes | No

    Default

    _OSC_RCIO6_1H
    Is not what you want
    Try this
    __CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H

    Then in your code
    DEFINE OSC ??
    ?? being the speed of your external
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    The datasheet for the PIC18F2520 shows "ECIO" for "external clock with IO on RA6, and the P18F2520.INC file in MPASM sort of modified that to "_OSC_ECIO6_1H", so that's what I used. Using "_OSC_HS_1H", works, but gives me the same 25 second wait at power-up. I'm not using a crystal, I'm using an external oscillator/clock.

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


    Did you find this post helpful? Yes | No

    Default

    What exactly are you using for a clock? Is it running?
    What is the speed?
    Do you have DEFINE OSC xx in your code?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Once it finally starts does it run correctly?
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    Yes, it does. Regarding the EC settings, I tried using "_OSC_EC_1H", and did verify that I was getting 5 MHz (1/4 freq), out on A6. I'll be glad when this "CONFIG WIZARD" is working.

  11. #11
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I didn't see your other questions... I'm using an external 20 MHz oscillator., and "DEFINE OSC 20" is in my code. I didn't have any trouble setting EITHER HS or EC settings (wierd), but it's the power-up delay that's confusing. Don't see a reason for it.

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


    Did you find this post helpful? Yes | No

    Default

    HS should be it. OSC input on both OSC pins.

    What about MCLR?
    Is it pulled high?
    Since the time-outs occur from the POR pulse, if MCLR
    is kept low long enough, all time-outs will expire. Bringing
    MCLR high will begin execution immediately
    (Figure 4-5). This is useful for testing purposes or to
    synchronize more than one PIC18FXXXX device
    operating in parallel.
    Dave
    Always wear safety glasses while programming.

  13. #13
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I don't know why HS should be it. EC should be it. I'm using an External OSC. Input is only on pin A7. MCLR is pulled high w/ 4.7K, and snaps high immediately on power up.

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


    Did you find this post helpful? Yes | No

    Default

    When you said you were not using a crystal I got to thinking resonator.
    You can use HS mode, OSC2 will just be an open pin.

    As for your problem I am at a loss.
    Maybe there is something at the beginning of your code messing things up?
    Dave
    Always wear safety glasses while programming.

  15. #15
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    This is my entire program, and I get a 25 sec. delay until the LED goes on.

    Code:
    ASM
         ;PORT A 
         CLRF PORTA 
         MOVLW 07h 
         MOVWF ADCON1                           ;A/D'S OFF 
         MOVWF 07h 
         MOVWF CMCON                            ;COMPARATORS OFF  
         MOVLW 00000000b                        ;PIN DIRECTION PORT A  
         MOVWF TRISA 
    ENDASM
    
    DEFINE OSC 20                                
    LOW PORTA.6                                     'TURN LED ON
    STOP

    Thanks anyway, Dave!

Members who have read this thread : 2

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