12F629 config help for newcomer


Closed Thread
Results 1 to 9 of 9
  1. #1

    Default 12F629 config help for newcomer

    Hi All

    Best whises,

    As i'm a hobby programmer i need some help from the PRO's

    This is the first time i'm going to use a 12F629 (before i used 16F628)

    I want to do the following

    GPIO.0 input
    GPIO.1 output
    GPIO.2 input
    GPIO.3 led
    GPIO.4 dtmfout
    GPIO.5 external clock input

    Can anyone help me to configure the registers and TRIS ?
    Also the EPIC programmer ?
    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi RFsolution,

    The GP3 on a 12F629 is input only, so you'll need to move the LED to a different pin.

    Are any of the inputs an analog signal? or are they all digital? The 629 doesn't have A/D, but it does have a comparator module for analog signals.

    We can figure out the configs etc. once you decide where to move the LED.

    Best regards,
      Darrel

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel for your help

    The inputs and outputs are just logic 0 or 1
    Except the dtmf out

    I can use the following pinout:

    GPIO.0 input
    GPIO.1 output
    GPIO.2 led
    GPIO.3 input
    GPIO.4 dtmfout
    GPIO.5 external clock input (4 mhz clockout from another device)

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The first thing to do, is to make a backup of the 12F629.INC file in the PBP directory, just in case you need to restore it again later. Then open it up with Notepad and put a semicolon in front of the <pre>; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF</pre> line, and save the file.

    This removes the default configuration for that chip, and allows you to set the __config value in your program. Just remember that you'll need to set the config in every program you write for the 12F629, unless you restore the original .INC file.

    The EPIC program will accept these values, so you won't have to worry about setting it up every time.

    Now add this line to the beginning of your program:
    <pre>@ __config _EC_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF</pre>
    Note the 2 underscores before config.

    _EC_OSC &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;se lects the external oscillator and enables GP4 as general I/O
    _MCLRE_OFF &nbsp;&nbsp;&nbsp;disables Master Clear and enables GP3 for input

    Add these to the program and you should be set.
    <pre>CMCON = 7 ' Set GP<2:0> to Digital, Disable comparator<br>TRISIO = %111001 ' Set GP<2:1> to Output</pre>
    DTMFOUT will set GP4 to output the first time you use it.

    HTH,
    &nbsp;&nbsp;Darrel

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel

    Thanks for your help

    The program is working, all I/O are working

    I modified the 12F62.inc file in the PBP dir as suggested:
    ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

    and add the following in my code:
    @ __config _EC_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF

    PBP is generating an error, if i comment the @ string and set the fuses by hand in Epic it is all working

    Any idea why the @ __config _EC_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF
    is not working ?

    Walter


    Happy Newyear

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hmm, that's odd. I just double checked to make sure, and it compiles fine here.

    What error is it giving you?

    Are you sure you edited the <b>12F629.INC</b>, not the 12F675.inc

    Did you cut&paste, or re-type the line. If you re-typed it here's a few things to check.

    There must be at least 1 space between the @ symbol and the __config.
    The __config has 2 underscores.
    There must also be a space between __config and _EC_OSC

    If that doesn't fix it, let me know what the error code is.

    Darrel

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel

    thanks again for your reply

    I already finished the small project by setting epic manualy
    which is not a good idea as i did a lot of programming to test the project hihi (know the epic win menu's by hart)

    This is what i get if i try to compile this small pbp code
    I use PBP 2.43, codestudio and epic 2.41
    I did select 12F629 as device

    Error UNTITLED.ASM 40:[235] opcode expected instead of '__config'

    Here is the pbp code:



    @ __config _EC_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF
    CMCON = 7 ' Set GP<2:0> to Digital, Disable comparator
    TRISIO = %011001 ' Set GP<2:1> to Output

    loop:
    high gpio.2
    pause 500
    low gpio.2
    pause 500
    goto loop

    Here is my 12F629.INC file which is in c:\pbp\pbp243\

    ;************************************************* ***************
    ;* 12F629.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2002 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 09/27/02 *
    ;* Version : 2.43 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    include 'M12F629.INC' ; PM header
    device pic12F629, intrc_osc, wdt_on, pwrt_on, mclr_on, protect_off
    XALL
    NOLIST
    else
    LIST
    LIST p = 12F629, r = dec, w = -302
    INCLUDE "P12F629.INC" ; MPASM Header
    ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

    NOLIST
    endif
    LIST

    Thanks again for your help

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Rats, did it again,

    I keep forgetting that some people still use <b>PM</b> as the assembler.

    I always use <b>MPASM</b>, and that's the info I gave you before.

    So for PM.

    Comment out the

    <pre> device pic12F629, intrc_osc, wdt_on, mclr_on, protect_off</pre>line in the 12F629.INC file. and add this one to your program instead.

    <pre>@ device pic12F629, ec_osc, wdt_on, mclr_off, protect_off</pre>
    Sorry about that!!!!!!

    &nbsp;&nbsp;Darrel

  9. #9


    Did you find this post helpful? Yes | No

    Default re

    thanks Darrel

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. 18F4550 Bootloader enter via eeprom setting
    By bradb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 23:51
  3. Error 0X0000008E when connecting a 18F2550 USB HID
    By FranciscoMartin in forum USB
    Replies: 8
    Last Post: - 16th October 2008, 17:20
  4. PortE problems (PIC18F4455)
    By RubenR in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 12th July 2006, 15:26
  5. Installation sequence
    By Demon in forum General
    Replies: 23
    Last Post: - 11th July 2006, 03:56

Members who have read this thread : 1

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