PDA

View Full Version : 12F629 config help for newcomer



RFsolution
- 30th December 2003, 16:51
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

Darrel Taylor
- 30th December 2003, 21:37
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

RFsolution
- 30th December 2003, 22:05
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)

Darrel Taylor
- 31st December 2003, 10:23
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;selects 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

RFsolution
- 2nd January 2004, 00:21
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

Darrel Taylor
- 2nd January 2004, 03:23
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

RFsolution
- 4th January 2004, 15:14
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

Darrel Taylor
- 4th January 2004, 22:59
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

RFsolution
- 4th January 2004, 23:03
thanks Darrel