External osc defines


Closed Thread
Results 1 to 21 of 21

Hybrid View

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

    Default External osc defines

    Hi Insiders,

    Iīm trying to convince a Pic16F628A to work at 20MHz (yes it is a 20Mhz device) with an external canned oscillator

    but i donīt get the right configs:

    @config_EXTCLK_OSC

    this shows no error when compiled but the setup doesnīt work

    this is my simple testcode.

    NEVER GOT ANY 20MHZ DEVICE WORKING!!!! only 10MHz or below.

    '************************************************* *******************************************
    ' 16F628A 4 Mhz crystal
    ' damn program should blink an LED every time a pulse goes into RB.0
    ' later a value should be serial loaded and set a delay before the blink pulse
    '************************************************* *******************************************

    '
    ' DEFINITIONS


    @config_EXTCLK_OSC


    CMCON=%00000111
    led var portb.7



    ' START OF MAIN PROGRAM
    '
    CMCON = 7 ' RA0-RA3 are digital I/O
    TRISA = 0 ' PORT A is output
    TRISB = 1 ' RB0 is Input others output



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


    END ' End of program

  2. #2
    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.

  3. #3
    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

  4. #4
    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!

  5. #5
    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

  6. #6
    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?

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