12F683 - how to set it to use external 4 MHz clock?


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62

    Default 12F683 - how to set it to use external 4 MHz clock?

    Hi there,

    I'm new to all this PIC business but loving it! I'm using a 12F683 to output a HPWM on pin 5 no problem. I'm also trying to bit bang data to it on the serial but on pins 6/7, which generally works but does get some garbage through. I've opted to fit a 4 MHz crystal oscillator to pins 2/3. My problem is non-familiarity with PBP! I've been looking at how to set the PIC to use the external oscillator instead of the internal however PBP just gives an error. I've been reading for hours and seem to be getting myself stuck in a loop!
    The error I'm getting at the moment for:

    @ DEVICE XT_OSC
    DEFINE OSC 4

    is:

    Warning[207] e:\.............\test.asm 47 : Found label after column 1. (DEVICE)
    Error[122] e:\...............\test.asm 47 : Illegal opcod (XT_OSC)

    I know it is going to be something stupid that I've not done but just getting lost in all the jargon.

    Cheers

    Jimbo

  2. #2
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default No spaces

    There must be no spaces before @ statement.

    "@" must be at the begining of row.

  3. #3
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62


    Did you find this post helpful? Yes | No

    Default

    Hi there,

    Many thanks for your prompt reply. I now accepts the @DEVICE bit but says XT_OSC is an illegal opcode (also tried _XT_OSC).

    Any ideas?

    Cheers

    Jimbo

  4. #4
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    - xt_osc is an illegal opcode


    i think you use mpasm.

    USE PM.

    DONT SELLECT "USE MPASM BOX" AT THE COMPILE AND PROGRAM OPTIONS.

  5. #5
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62


    Did you find this post helpful? Yes | No

    Default

    It progressess!

    It's actually picbasic pro compiler 2.50 I'm using. I unticked 'use mpasm' box as you suggested.

    Now it says "Error TEST.ASM 47 : [235] opcode expected instead of _xt_osc"

    ???!

  6. #6
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Remove "_"

    use
    @ device xt_osc
    Attached Images Attached Images  
    Last edited by mehmetOzdemir; - 25th September 2009 at 13:58.

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


    Did you find this post helpful? Yes | No

    Default

    For PM
    Code:
    @ device  pic12F683, xt_osc, wdt_on, mclr_on, protect_off
    FOR MPASM
    Code:
    @ __config _XT_OSC & _WDT_ON & _MCLRE_ON & _CP_OFF
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62


    Did you find this post helpful? Yes | No

    Default

    Hi there,

    Run into more problems now lol. With 'use mpasm' unticked, I can no longer use mplab ide to build/upload the file to the pic. It gives a stream of errors.

    However, if I tick the 'use mpasm' again, I get errors in picbasic pro:

    Warning[207] e:\.......\sertest.asm 93 : Found label after column 1. (device)
    Error[122] e:\.......\sertest.asm 93 : Illegal opcode (pic12F683)

    for code:

    #####################################
    @ device pic12F683, xt_osc, wdt_on, mclr_on, protect_off
    DEFINE OSC 4
    Include "modedefs.bas"
    OSCCON = %00001000
    ANSEL=0
    CMCON0=%00000111
    pw var byte
    led var gpio.4
    OSCCON=%01110000
    oldpwm var byte
    #########################################

    etc...

    I think I basically don't understand how these applications work together creating multiple files that are all linked together... I come from the old school - one program and run!

  9. #9
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62


    Did you find this post helpful? Yes | No

    Default

    oooh further to my last I think I misunderstood what you said Dave... so I switched to the:

    @ __config _XT_OSC & _WDT_ON & _MCLRE_ON & _CP_OFF

    and now the error I get in the compiler is Error[118] e:\....\sertest.asm 93 : Overwriting previous address contents (2007)

    ?!

    Is this perhaps related to my program and not this config aspect?

Similar Threads

  1. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  2. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 04:08
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31
  5. How to set external clock source in PBP
    By TurboLS in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 19th February 2005, 15:56

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