PDA

View Full Version : Help with pic 12f629



gutisie
- 15th September 2010, 21:00
Hi there,

I am new to this worl of pics, and know very little about them. I started this as a new hobby, and got really into it.

At the moment, I am having difficulties to make my pic count upto 3 presses of a switch connected to pin 2, and turn off a led connected to pin 1.

Please any advice will be much appreciated.

Best regards.
Frank.


cnt VAR BYTE
boton VAR GPIO.2
mosfet VAR GPIO.1

CMCON = 7

'Ports
Output mosfet
Input boton

cnt=0
boton = 1

'Begin Program
TEST:
high mosfet
count 2, 1, cnt
if cnt = 3 then
cnt = 0
low mosfet
pause 1000
endif


GOTO TEST
end

mackrackit
- 15th September 2010, 22:29
Welcome to the forum.

Maybe this will get you started.

CHECK:
high mosfet
IF boton = 0 THEN TEST
GOTO CHECK

TEST:
cnt = cnt +1
IF cnt = 3 THEN OFF_LED
RETURN

OFF_LED:
cnt = 0
low mosfet
pause 1000
GOTO CHECK

gutisie
- 16th September 2010, 18:12
Thanks Dave!!! grate stuff!!!
I will post the results later on.

Thanks again. :)

gutisie
- 16th September 2010, 18:36
No Dave...no luck....I am going mad!!!....:confused::confused::confused:

mackrackit
- 16th September 2010, 18:48
What exactly is happining?

cncmachineguy
- 16th September 2010, 19:11
now to show off my newbieness. If that is the entire program, won't he need SOME sort of init type stuff? setup tris,osc,...? something?

mackrackit
- 16th September 2010, 19:26
TRIS is taken care of in the HIGH/LOW commands.
The vars will need defined. The OP had that.
DEFINE the OSC and set the configs someplace. Figured the OP had those too. Seemed the code was running, just not running as expected.

mackrackit
- 16th September 2010, 19:34
DOH!!
That chip has an ADC I think.
Add
ANSEL=%00000000

http://www.picbasic.co.uk/forum/showthread.php?t=561

cncmachineguy
- 16th September 2010, 19:34
Is If_then a goto or gosub? I am used to it being a goto unless gosub is called out. But I clearly haven't read my PBP book yet. - sorry

If goto then return will break the code - yes?

mackrackit
- 16th September 2010, 19:41
Bert,
You are correct. Thanks for catching that.

cncmachineguy
- 16th September 2010, 19:47
so please confirm:

test should have "goto check" instead of "return"?

mackrackit
- 16th September 2010, 20:01
Yes

that pretty much does it for me today. Too many DOHS.

cncmachineguy
- 16th September 2010, 20:41
Yes

that pretty much does it for me today. Too many DOHS.

you intended to right?

I thought you were just giving us new folks a chance to help :) Better to teach than to do. that way we learn something.

gutisie
- 16th September 2010, 21:04
hi guys,

thanks all for your help, but no luck so far, before the last suggested changes, the code will just stay on forever.
Now, with the ANSEL part, just wont compile, it says "syntax error".

Removing the ansel part, it compiles, i run it and after the boton is pressed it jumps direct to the last part of the code (off_led/off_mosfet)

This is my actual code:



cnt VAR BYTE
boton VAR GPIO.2
mosfet VAR GPIO.1


CMCON = 7

'Ports
Output mosfet
Input boton

cnt=0

CHECK:
high mosfet
IF boton = 0 THEN TEST
GOTO CHECK

TEST:
cnt = cnt + 1
IF cnt = 3 THEN OFF_MOSFET
GOTO CHECK

OFF_MOSFET:
cnt = 0
low mosfet
pause 1000
GOTO CHECK
end


Any sugestions?
Much appreciated, and thanks again.

cncmachineguy
- 16th September 2010, 21:18
Having no idea what your circuit looks like, my first guess is your button is bouncing. So when you press it, the pic sees any number of presses during that short time between starting to make contact and fully pressed. To test, add a pause in the "test" :

TEST:

pause

cnt = cnt + 1
IF cnt = 3 THEN OFF_MOSFET
GOTO CHECK

I don't know the exact format of pause, but set it for something big like 100mS. That way for every button press, execution waits to allow your finger to catch up with the pic.

gutisie
- 16th September 2010, 21:26
Thanks, My circuit is just real pic simulator, so no circuit yet.
but it should be something like a push boton normaly open, and a led with the resistor.
I think it is the ansel thing, to set things digital.

Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie. :(

Well, thanks again for your help guys.
I will keep doing as you say.
Thanks.

cncmachineguy
- 16th September 2010, 21:45
Thanks, My circuit is just real pic simulator, so no circuit yet.
but it should be something like a push boton normaly open, and a led with the resistor.
I think it is the ansel thing, to set things digital.

Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie. :(

Well, thanks again for your help guys.
I will keep doing as you say.
Thanks.

I don't know if the simulator simulates switches as de-bounced or not. This is all the help I can be at this time, I too do not understand. It looks like it should be working to me. -Sorry

I will keep watching to see what the "pro's" have to say. :)

mackrackit
- 16th September 2010, 22:34
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
CMCON=7

cnt VAR BYTE
boton VAR GPIO.2
mosfet VAR GPIO.1

cnt = 0

CHECK:
IF boton = 0 THEN TEST
LOW mosfet
GOTO CHECK

TEST:
IF cnt < 3 THEN OFF_MOSFET
IF cnt => 3 THEN ON_MOSFET
GOTO CHECK

OFF_MOSFET:
PAUSE 100
IF boton = 0 THEN
low mosfet
cnt = cnt + 1
ENDIF
GOTO CHECK

On_MOSFET:
HIGH mosfet
pause 1000
low mosfet
cnt = 0
GOTO CHECK
end

mackrackit
- 16th September 2010, 23:17
you intended to right?

I thought you were just giving us new folks a chance to help :) Better to teach than to do. that way we learn something.

Nope, I made one of my many mistakes. I was planning to give the OP a basic working code like I just did for something to "start" with. Then if needed try to do a little "teaching".

Seems like a simple operation, but to make it work well some sort of de-bouncing and maybe an interrupt will be needed.

Acetronics2
- 17th September 2010, 10:02
Hi,

May be that one ???



'************************************************* ***************
'* Name : Bôton.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 17/09/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
DEFINE BUTTON_PAUSE 10 ' 10 is default value
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

cnt VAR BYTE
delay var byte

boton VAR GPIO.2
mosfet VAR GPIO.1


' ANSEL = 0 '12F675 for test
CMCON = 7
OPTION_REG.7 = 0 'Pullups enabled
WPU = %00000100

cnt = 0
GPIO = %00000110 ' Nosurprise startup ...
TRISIO = %00000100

'************************************************* *****************************
Detect: 'Button presses W/Debounce
'
delay = 0
BUTTON Boton ,0,255,0,delay,1,pressed
Pause 20 ' Slow Things down
GOTO Detect

'************************************************* *****************************
Pressed: ' Some > 10ms press detected
IF cnt < 3 Then

cnt = cnt + 1

ELSE

cnt = 0
LOW mosfet
PAUSE 1000

ENDIF

WHILE !Boton : WEND ' Wait Boton release !!!
goto detect

END




Alain

gutisie
- 17th September 2010, 20:08
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
CMCON=7

cnt VAR BYTE
boton VAR GPIO.2
mosfet VAR GPIO.1

cnt = 0

CHECK:
IF boton = 0 THEN TEST
LOW mosfet
GOTO CHECK

TEST:
IF cnt < 3 THEN OFF_MOSFET
IF cnt => 3 THEN ON_MOSFET
GOTO CHECK

OFF_MOSFET:
PAUSE 100
IF boton = 0 THEN
low mosfet
cnt = cnt + 1
ENDIF
GOTO CHECK

On_MOSFET:
HIGH mosfet
pause 1000
low mosfet
cnt = 0
GOTO CHECK
end

Hi guys, thanks again, your are wonderfull!!.

Unfortunately, this code gives me error 118.

Thanks.
Best regards.

mackrackit
- 17th September 2010, 20:27
If you are setting the configs in code space comment that line out.

gutisie
- 17th September 2010, 20:38
Hi Dave, yes thats it.

When I delete the first 2 lines "define ocs" and "@...", both codes compile ok.

Unfortunately, the behaviour is basicaly the same....they start with led off, and it should be on, more over, the counting is not regular, it depends in the speed of the click.
Some times, it goes off at 3, others at 5...etc....

I dont know....it is very over me.
I have tried to cut here and there taking ideas from both codes, but it does not work either.

I have to mention, that the clicks will be very fast, we could have posibly.......20 clicks per second, but we need to stop the mosfet after counting 3 clicks, hence the pause for 1 second.

I am sorry, my spanish brain is too tyre and can not speak properly.

Thanks for helping me guys.
Much appreciated.

Best regards.

mackrackit
- 17th September 2010, 22:55
You might not need the
DEFINE OSC 4
but it is a good idea to put it in. That is the line that tell PBP how fast the chip is running. I assume you are using the 4MHz internal.

The state of the mosfet/led depends on how you have the hardware setup. Just change the LOW/HIGH around to do what you want.

Like I said before. This will need a good denouncing routine to work correctly. Now that you say the button could be pressed at 20HZ even more so. What is going to press a button that fast?

Here are a couple of threads that might help you.
http://www.picbasic.co.uk/forum/showthread.php?t=13516
http://www.picbasic.co.uk/forum/showthread.php?t=2180

Read them all the way through.

gutisie
- 18th September 2010, 11:25
Hi dave,

Thanks for your help, I will have a look at the links later.

Yes you are right, I am using the internal oscillator at 4 mhz.

The botton is pressed by a piston.
So I need to stop the piston after 3 pulses.

Thanks.

mackrackit
- 18th September 2010, 12:12
Is it really a button type switch or some other kind of sensor?

I ask because a mechanical switch may not be the best at high speeds.

And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

Just thoughts....

gutisie
- 18th September 2010, 13:28
Is it really a button type switch or some other kind of sensor?

I ask because a mechanical switch may not be the best at high speeds.

And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.

If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.

Just thoughts....

yes the idea is a proper botton switch, the wired to pull it low it is some thing that i dont understand.
The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.

I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
Otherwise this can be very long...

Thanks for the help guys.
Best regards.

Acetronics2
- 18th September 2010, 13:54
The botton is pressed by a piston.
So I need to stop the piston after 3 pulses.

Thanks.

Some Hall effect sensor would be to consider, instead ... :rolleyes:

just me ...

Alain

cncmachineguy
- 18th September 2010, 14:25
The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.

You should ALWAYS assume EVERY mechanical contact switch bounces. The effects can be made less with tricks like DAVE suggests, and with higher quality snap type switches. But heres the thing: as 1 contact approaches the other, they WILL arc. The arc is the "bounce" this happens when opening and closing. Also, switches HATE DC. So if you want this to work for any lengh of time, be certain the switch is DC rated. DC causes the contacts to "plate" and then the bounceing gets worse until the switch quits all together.



I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
Otherwise this can be very long...

Thanks for the help guys.
Best regards.

Not a bad approace at all. Good luck! :)

Acetronics2
- 18th September 2010, 17:40
# 20 updated to our friend's desires ... :rolleyes:

Alain

gutisie
- 18th September 2010, 22:43
# 20 updated to our friend's desires ... :rolleyes:

Alain

oooooomg!!!! you did it!!! it works!!!

but i had to change it a bit.
I will post the results later
I am still shaking....:rolleyes::rolleyes:

gutisie
- 26th September 2010, 12:17
hi, the code works fine under slow speed, it will count up to 3 and go off the led for 1 s, then on back again.

Please see actual code.


DEFINE OSC 4


cnt VAR BYTE
delay var byte

boton VAR GPIO.2
mosfet VAR GPIO.1


' ANSEL = 0 '12F675 for test
CMCON = 7
OPTION_REG.7 = 0 'Pullups enabled
WPU = %00000100

cnt = 0
GPIO = %00000110 ' Nosurprise startup ...
TRISIO = %00000100

'************************************************* *****************************
Detect: 'Button presses W/Debounce
'
delay = 0
BUTTON Boton ,0,255,0,delay,1,pressed
' Slow Things down
GOTO Detect

'************************************************* *****************************
Pressed: ' Some > 10ms press detected
IF cnt <=1 Then 'tocount uptu 3, bigger values will add up.

cnt = cnt + 1

ELSE

cnt = 0
LOW mosfet
PAUSE 1000
high mosfet

ENDIF

WHILE !Boton : WEND ' Wait Boton release !!!
goto detect

END

I need much faster reading from the pic, other wise, it will count moreto go off, on breadboard, it may not even go on again.
For some oscure reason, my Pbasic compiler, does not like the configuration line you put, after the OSCAL SETTING, in line one.
So I have to set it manualy, using software configuration bit facility.

See my circuit, but, instead of 2 only one led, on GP1, and Push boton on GP2.

Best regards.
http://img18.imageshack.us/img18/1039/esquemau.png (http://img18.imageshack.us/i/esquemau.png/)


Thanks Acetronics.

Acetronics2
- 26th September 2010, 16:11
Hi,



oooooomg!!!! you did it!!! it works!!!


Keep cool ... there's no miracle in that ... ;)

If you need faster response ... forget about your pushbutton !!! :rolleyes: Button bouncings will give a totally random functionning ...
another "detector" type has to be used.

Now, modified code reacts for 2 pushings only ???

The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

Alain

gutisie
- 27th September 2010, 17:52
Hi,



Keep cool ... there's no miracle in that ... ;)

If you need faster response ... forget about your pushbutton !!! :rolleyes: Button bouncings will give a totally random functionning ...
another "detector" type has to be used.

Now, modified code reacts for 2 pushings only ???

The obscure reason is you use PM as an assembler and not MPASM with your Microcode IDE ...

Alain

Hi thanks for your response, much appreciated.

The compiler, i use is Pbasic?..with Mplab ide....these are at least the software names.
Do you need a screen capture of the compiling results?

And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

Any way....Ir sensors?...proximity switches?....

I once more depend on your wisdom master....:p

Acetronics2
- 27th September 2010, 20:09
Some testings show the minimum time for 3 pushes is ... around 78 ms !!! @ 10ms debounce time and a Pause 0 for scanning ...

so, I really doubt any finger could do that !!! :D



And about the button...what type would you use?...I am absolutly clue less.....and desperate...and tyre...and bald....and...etc...

Any way....Ir sensors?...proximity switches?....


so What moves the button ??? :confused:

Alain

gutisie
- 28th September 2010, 18:15
Hi Ace,

Thanks for your reply.

The button is pressed by the piston on a gear box. As i said on other post, my actual reading is 15 to 20 cycles per sec. And i need to stop the piston, after 3 cycles.

I have some Ir sensors. But putting them inside the gearbox or some where around, it is not a good idea.

Hence, buttons is the best for my application i think.

Thanks.:)

Acetronics2
- 28th September 2010, 19:41
Hi Ace,

, my actual reading is 15 to 20 cycles per sec. And i need to stop the piston, after 3 cycles.

Thanks.:)

20 c/s is 50 ms ... 3 cycles are 150 ms ...

electronics works for 80 ms per 3 cycles ...

SO ... if your switch is a good quality / low inertia one... it Works !!! :rolleyes:

but, of course ... if it works in oil ... ( gear box ...)

magnetic detector looks to be THE thing ... I think telemecanique also have nice proximity switches that can reach 50 or 100 Hz ... ( I have some home ...)

at least it's no more an electronics problem ...;)

Alain

mackrackit
- 28th September 2010, 21:08
Why not a mag/prox sensor on a connecting rod or gear.
Maybe even find a gear that is 3/1??

gutisie
- 30th September 2010, 21:10
20 c/s is 50 ms ... 3 cycles are 150 ms ...

electronics works for 80 ms per 3 cycles ...

SO ... if your switch is a good quality / low inertia one... it Works !!! :rolleyes:

but, of course ... if it works in oil ... ( gear box ...)

magnetic detector looks to be THE thing ... I think telemecanique also have nice proximity switches that can reach 50 or 100 Hz ... ( I have some home ...)

at least it's no more an electronics problem ...;)

Alain

Thanks guys for your reply.

So Alain, telemec?...ummm....I think they dont sell m5 or less like omron...any way...there are a bit expensive.

Could you guys put me a link of a good button for this application?, Ebay?...thanks.
Regards.

gutisie
- 15th October 2010, 19:00
Hello All,

After trying with different sensor, and switches, I have found out that the reason for the strange behaviour, or mal functioning of the code, it is due to the excess of current supply.

I have notice that when you have the "finger" on any of the conections, the systems works!!, but if you remove the finger, starts to go nuts again. :p

So at the moment i am supplying from 3v = 2xAA bateries. I will put a LM317 to allow only 250ma to go through.

See if that helps.

I will post my results.

Best regards.

And thank you all for your help.

gutisie
- 16th October 2010, 20:08
Hello All,

I have put the voltage regulator, configured as a corrent regulator, allowing to pass only 250 mmA to the pic.

Still does not work....if i put the finger on any conection...no problem, it works. But as soon as i remove my finger fron the conection, it goes dead.

Why?...i thoght it was because the current, but this experiment has proved that it is not that. Hence, i am starting to believe that it may be because configuration in the pic.

After having a closer look at the code, i notive pull ups where enable, should not that option be of sice i have pull up resistors in the circuit as shown, ?/...or is it the other way around?..

Any body please?

Ace?...:p

Best regards.

mackrackit
- 17th October 2010, 10:51
Sounds like you need a capacitor across VDD/VSS.
You posted a schematic earlier but said this is what I have with this and that exception and you also said your were using the software to set the configs.

If we knew what the configs are set to and how the chip is connected it may help.

gutisie
- 17th October 2010, 21:49
Hello Dave,

thanks for your reply.

I will post later a capture of the configuration bits.

About the capacitor across, I have allready tried, but nothing.

Regards.
Thanks for your help.

gutisie
- 17th October 2010, 21:58
HERE ARE THE CONFIG BITS

http://img217.imageshack.us/img217/6515/configi.png (http://img217.imageshack.us/i/configi.png/)

Thanks.

mackrackit
- 17th October 2010, 22:38
I never liked setting the fuses with the programing software, always seemed to give trouble. So set the fuses in the *.inc or code space.

Some things to try.
Turn BODEN to OFF

From the schematic posted the resistance at MCLR may be a little to high. Test by turning MCLRE to OFF.

gutisie
- 19th October 2010, 18:16
hi Dave,

Excuse my ignorance, what lines do i put in the code exactly?

thanks.

Best regards.

mackrackit
- 19th October 2010, 20:25
DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _BODEN_OFF & _CP_OFF
I think that is correct, I am not in the shop...
And comment out the *.inc file int your PBP directory.

Now when you look at the configs in MPLAB check the box set fuses in code. That dialog box will now tell you what the fuses are set for after you compile. This is a good way to make sure things are like you want.

gutisie
- 20th October 2010, 18:54
Hi there,

Thanks Dave for your reply, I am a bit lost, sorry for my incompetence.

Please find the *inc file, below. Could you please tell me which ones I have to ";"?

Also, Dont i have to reference in the code, like, list p=12f629 or something like that?

Thanks.

Best regards.
Frank.

gutisie
- 20th October 2010, 18:55
if i attache the code it will help i know....:D



LIST
; P12F629.INC Standard Header File, Version 1.04 Microchip Technology, Inc.
NOLIST

; This header file defines configurations, registers, and other useful bits of
; information for the PIC12F629 microcontroller. These names are taken to match
; the data sheets as closely as possible.

; Note that the processor must be selected before this file is
; included. The processor may be selected the following ways:

; 1. Command line switch:
; C:\ MPASM MYFILE.ASM /PIC12F629
; 2. LIST directive in the source file
; LIST P=PIC12F629
; 3. Processor Type entry in the MPASM full-screen interface

;================================================= =========================
;
; Revision History
;
;================================================= =========================
;1.04 07/01/02 Updated configuration bit names
;1.03 05/10/02 Added IOC register
;1.02 02/28/02 Updated per datasheet
;1.01 01/31/02 Updated per datasheet
;1.00 08/24/01 Original

;================================================= =========================
;
; Verify Processor
;
;================================================= =========================

IFNDEF __12F629
MESSG "Processor-header file mismatch. Verify selected processor."
ENDIF

;================================================= =========================
;
; Register Definitions
;
;================================================= =========================

W EQU H'0000'
F EQU H'0001'

;----- Register Files------------------------------------------------------

INDF EQU H'0000'
TMR0 EQU H'0001'
PCL EQU H'0002'
STATUS EQU H'0003'
FSR EQU H'0004'
GPIO EQU H'0005'

PCLATH EQU H'000A'
INTCON EQU H'000B'
PIR1 EQU H'000C'

TMR1L EQU H'000E'
TMR1H EQU H'000F'
T1CON EQU H'0010'

CMCON EQU H'0019'

OPTION_REG EQU H'0081'

TRISIO EQU H'0085'

PIE1 EQU H'008C'

PCON EQU H'008E'

OSCCAL EQU H'0090'

WPU EQU H'0095'
IOCB EQU H'0096'
IOC EQU H'0096'

VRCON EQU H'0099'
EEDATA EQU H'009A'
EEDAT EQU H'009A'
EEADR EQU H'009B'
EECON1 EQU H'009C'
EECON2 EQU H'009D'

;----- STATUS Bits --------------------------------------------------------

IRP EQU H'0007'
RP1 EQU H'0006'
RP0 EQU H'0005'
NOT_TO EQU H'0004'
NOT_PD EQU H'0003'
Z EQU H'0002'
DC EQU H'0001'
C EQU H'0000'

;----- GPIO Bits --------------------------------------------------------

GP5 EQU H'0005'
GPIO5 EQU H'0005'
GP4 EQU H'0004'
GPIO4 EQU H'0004'
GP3 EQU H'0003'
GPIO3 EQU H'0003'
GP2 EQU H'0002'
GPIO2 EQU H'0002'
GP1 EQU H'0001'
GPIO1 EQU H'0001'
GP0 EQU H'0000'
GPIO0 EQU H'0000'



;----- INTCON Bits --------------------------------------------------------

GIE EQU H'0007'
PEIE EQU H'0006'
T0IE EQU H'0005'
INTE EQU H'0004'
GPIE EQU H'0003'
T0IF EQU H'0002'
INTF EQU H'0001'
GPIF EQU H'0000'

;----- PIR1 Bits ----------------------------------------------------------

EEIF EQU H'0007'
ADIF EQU H'0006'
CMIF EQU H'0003'
T1IF EQU H'0000'
TMR1IF EQU H'0000'

;----- T1CON Bits ---------------------------------------------------------

TMR1GE EQU H'0006'
T1CKPS1 EQU H'0005'
T1CKPS0 EQU H'0004'
T1OSCEN EQU H'0003'
NOT_T1SYNC EQU H'0002'
TMR1CS EQU H'0001'
TMR1ON EQU H'0000'

;----- COMCON Bits --------------------------------------------------------

COUT EQU H'0006'
CINV EQU H'0004'
CIS EQU H'0003'
CM2 EQU H'0002'
CM1 EQU H'0001'
CM0 EQU H'0000'

;----- OPTION Bits --------------------------------------------------------

NOT_GPPU EQU H'0007'
INTEDG EQU H'0006'
T0CS EQU H'0005'
T0SE EQU H'0004'
PSA EQU H'0003'
PS2 EQU H'0002'
PS1 EQU H'0001'
PS0 EQU H'0000'

;----- PIE1 Bits ----------------------------------------------------------

EEIE EQU H'0007'
ADIE EQU H'0006'
CMIE EQU H'0003'
T1IE EQU H'0000'
TMR1IE EQU H'0000'

;----- PCON Bits ----------------------------------------------------------

NOT_POR EQU H'0001'
NOT_BOD EQU H'0000'

;----- OSCCAL Bits --------------------------------------------------------

CAL5 EQU H'0007'
CAL4 EQU H'0006'
CAL3 EQU H'0005'
CAL2 EQU H'0004'
CAL1 EQU H'0003'
CAL0 EQU H'0002'

;----- IOCB Bits --------------------------------------------------------

IOCB5 EQU H'0005'
IOCB4 EQU H'0004'
IOCB3 EQU H'0003'
IOCB2 EQU H'0002'
IOCB1 EQU H'0001'
IOCB0 EQU H'0000'

;----- IOC Bits --------------------------------------------------------

IOC5 EQU H'0005'
IOC4 EQU H'0004'
IOC3 EQU H'0003'
IOC2 EQU H'0002'
IOC1 EQU H'0001'
IOC0 EQU H'0000'

;----- VRCON Bits ---------------------------------------------------------

VREN EQU H'0007'
VRR EQU H'0005'
VR3 EQU H'0003'
VR2 EQU H'0002'
VR1 EQU H'0001'
VR0 EQU H'0000'

;----- EECON1 Bits --------------------------------------------------------

WRERR EQU H'0003'
WREN EQU H'0002'
WR EQU H'0001'
RD EQU H'0000'

;================================================= =========================
;
; RAM Definition
;
;================================================= =========================

__MAXRAM H'FF'
__BADRAM H'06'-H'09', H'0D', H'11'-H'18', H'1A'-H'1F', H'60'-H'7F'
__BADRAM H'86'-H'89', H'8D', H'8F', H'91'-H'94', H'97'-H'98', H'9E'-H'9F', H'E0'-H'FF'

;================================================= =========================
;
; Configuration Bits
;
;================================================= =========================

_CPD_ON EQU H'3EFF'
_CPD_OFF EQU H'3FFF'
_CP_ON EQU H'3F7F'
_CP_OFF EQU H'3FFF'
_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_MCLRE_ON EQU H'3FFF'
_MCLRE_OFF EQU H'3FDF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FEF'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FF7'
_LP_OSC EQU H'3FF8'
_XT_OSC EQU H'3FF9'
_HS_OSC EQU H'3FFA'
_EC_OSC EQU H'3FFB'
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_EXTRC_OSC_NOCLKOUT EQU H'3FFE'
_EXTRC_OSC_CLKOUT EQU H'3FFF'

LIST

mackrackit
- 20th October 2010, 19:20
The file you have posted DO NOT modify. That is the MPASM file that has all the chip details. At the bottom of the file all of the config options are listed.

The file you need to modify is in the PBP directory.
Make it look like this.

;************************************************* ***************
;* 12F629.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2005 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 08/31/05 *
;* Version : 2.46a *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M12F629.INC' ; PM header
device pic12F629, intrc_osc_noclkout, wdt_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_OFF & _BODEN_OFF & _CP_OFF
NOLIST
endif
LIST


Also, Dont i have to reference in the code, like, list p=12f629 or something like that?
No, PBP does that for you at compile time when it reads the above file.

gutisie
- 22nd October 2010, 18:02
Hi Dave,

Thanks for your help.

I have tried and it gives me compiling error.

So i commented out the line in the pbp directory as follow, but still gives me error:

else
LIST
LIST p = 12F629, r = dec, w = -302
INCLUDE "P12F629.INC" ; MPASM Header
;__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _BODEN_OFF & _CP_OFF
NOLIST
endif
LIST

Also, this is the message i get when compiling:
Executing: "C:\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p12F629 "3basic.bas"
Executing: "C:\PBP\PBPW.EXE" -ampasmwin -k# -p12F629 "3basic.bas"
PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
All Rights Reserved.

ERROR: Unable to execute mpasmwin.Error[118] C:\USERS\SHAN-MONICA-SHISHAN\DOCUMENTS\PICPROYECTS\PIC12F629\3BASIC.ASM 90 : Overwriting previous address contents (2007)
Halting build on first failure as requested.
BUILD FAILED: Fri Oct 22 17:58:18 2010

Best regards.

mackrackit
- 22nd October 2010, 20:35
Overwriting error is when you set the configs in code space and do not comment the PBP *.inc file.... But you have done that.

Long directory paths cause problems also, yours is very long.

C:\USERS\SHAN-MONICA-SHISHAN\DOCUMENTS\PICPROYECTS\PIC12F629\3BASIC.ASM 90
Try moving your project directory closer to the root of the drive

C:\PICPROYECTS
In my opinion, it is a bad idea to store any user created content in "C:\USERS\".

gutisie
- 25th October 2010, 18:58
Hi Dave,

It didnt work, still gives me the same error.

I am just worried that my header it is not correct, it looks like this:


DEFINE OSC 4
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

cnt VAR BYTE
delay var byte
etc....

But It looks something is missing.....

I dont know....anyway, thanks all for you help.

Best regards.
Frank.