External osc defines


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Try this:

    @ __CONFIG_EXTCLK_OSC
    DEFINE OSC 20
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Make sure you call-out all config options you need in the config directive line. Otherwise
    they default to options you may not be aware of that can stop you dead in your tracks.

    /MCLR is by default reset, and LVP is by default on. If you only indclude _EXTCLK_OSC, then
    LVP is enabled, and can really screw things up.

    Give this a shot.

    Code:
      @ __config _EXTCLK_OSC & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
      
      DEFINE OSC 20 
      LED VAR PORTB.7
      CMCON = 7 ' RA0-RA3 are digital I/O
      PORTB = %01111111 ' set port latches
      TRISB = %01111111 ' RB7 is output, rest are inputs.
    
    main:
      led = 1
      pause 500
      led = 0
      pause 500
      goto main
    
      END ' End of program
    Regards,

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

  3. #3
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default 20MHz no go

    Hi Bruce,

    I tried your Program but it gave me a compilation error I didnīt understand something like out of memory.

    I tried Joes Define instead which at least showed no compilation error.

    My small setup sits on a veroboard and I tried to hold all Cu-lines as short as possible and used the some capacitors etc.

    99% of the time it didnīt work but some seconds the Led blinked as expected.

    Tried some other 20Mhz 16F628A but they showed all the same behavior. Scope said the canned Oscillator is ok,. tried to use different resistors in line, parallel , from +5V to signal because it could have an open collector output......

    In the evening I try again with a crystal. Damned!

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


    Did you find this post helpful? Yes | No

    Default

    To use this config directive you need to use the MPASM assembler, and comment out any
    MPASM config statments in the default PBP device header file.

    If you're using the PM assembler, then change it to;

    @ DEVICE EXTCLK_OSC, WDT_OFF, MCLR_OFF, LVP_OFF, PROTECT_OFF

    If you're still having trouble see this thread http://www.picbasic.co.uk/forum/showthread.php?t=543
    Regards,

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

  5. #5
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Mpasm

    Hi Bruce,

    Iīm using Micrchips MPASM and PBP 2.50

    Did you use 20 MHz on a veroboard?

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


    Did you find this post helpful? Yes | No

    Default

    I have never used vero board or a 20MHz canned type TTL clock oscillator, but I do use
    20MHz crystals & resonators on breadboards pretty often.

    What is the error you're seeing when you compile? The example I posted compiles fine here!

    Edit: Which PIC are you compiling for? There are differences in config options between some
    device types.
    Last edited by Bruce; - 12th February 2008 at 12:47. Reason: PIC type
    Regards,

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

  7. #7
    Join Date
    Jan 2008
    Location
    Selm, Germany
    Posts
    116


    Did you find this post helpful? Yes | No

    Talking Found mistake on design homepage

    Hi Guys!

    This works:

    '************************************************* *******************************************
    ' 16F628A 20Mhz extern canned Oscillator
    ' damn program should blink an LED
    ' Yeah Works!
    '************************************************* *******************************************

    @config_EXTCLK_OSC


    DEFINE OSC 20
    LED VAR PORTB.7
    CMCON = 7 ' RA0-RA3 are digital I/O

    TRISB = %01111111 ' RB7 is output, rest are inputs.

    main:
    led = 1
    pause 500
    led = 0
    pause 500
    goto main

    END ' End of program

    And heres the mistake:
    http://hobby_elec.piclist.com/e_pic8_8.htm

    Look at the osc wiring diagram: ext osc MUST be connected to RA6! hahahaha!

Similar Threads

  1. Internal vs. external osc for comms
    By mtripoli in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th January 2010, 14:58
  2. Replies: 1
    Last Post: - 28th January 2010, 22:15
  3. 18F1320 with external osc
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th February 2008, 22:32
  4. How to use an external oscillator
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th February 2008, 14:19
  5. External clock
    By Firegod in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th March 2007, 00:53

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