PDA

View Full Version : PIC12F629, useing all I/O pins



Jcee324
- 1st December 2004, 11:34
Hello

I am trying to use all the I/O pins on a PIC12F629 (all six of them). I have tried the program code on a PIC16F627 and it workes fine but it is the configuration of the I/O pins of the 12F629 I am worried about. My code is:


@ DEVICE pic12F629, MCLR_OFF
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT

'Port
trisio = %001100

'Variabler
Ra0 VAR GPIO.2 'Puls Y-axel 5
Ra1 VAR GPIO.3 'Rotationsriktning Y-axel 4

Rb4 VAR GPIO.0 'Utgång Y-Axel lila 7
Rb5 VAR GPIO.1 'Utgång Y-Axel rosa 6
Rb6 VAR GPIO.4 'Utgång Y-Axel röd 3
Rb7 VAR GPIO.5 'Utgång Y-Axel svart 2


I want to use the internal clock and use the mclr-pin as an input. Have I missed something? I hope I have because the program don't work very good.

I am glad for all the help I can get.
\Jonas
http://www.geocities.com/jcee324

Ingvar
- 1st December 2004, 13:16
Tjena Jonas,

You don't show the rest of your program. You need "CMCON = 7" somewhere in the beginning of your program. I would also recommend you to write something to the two missing bits in "trisio = %001100", just to make sure PBP gets everything aligned correctly. You should also add "DEFINE OSCCAL_1K 1" to calibrate the internal oscillator. You also need to make sure that your programmer actually sets the configuration to what you want, not all programmers do. If this won't make it work you'll need to post all of your code.

Harebra
/Ingvar

Jcee324
- 1st December 2004, 14:42
Hejsan Ingvar!

Well, once again I had forgot the "cmcon=7". Now my program seems to work. But!!! Now when I have programmed my 12F629 with the working program I can't reprogram it. The programmer answer that there is no pic connected. Why??? I have tried to reconnect the pic (thought it may be loose) but it wont help. I can't erase the pic either.

Does anyone know what to do????

\Jonas
http://www.geocities.com/jcee324

Dwayne
- 1st December 2004, 14:57
Hello Jcee,

J>>Now my program seems to work. But!!! Now when I have programmed my 12F629 with the working program I can't reprogram it. The programmer answer that there is no pic connected. Why??? <<

A couple of things. Make sure all pins are making contact.
and make sure you erase the chip before reprogramming. If you are trying to do serial programming ICSP, you will have to disconnect the pins that use the ICSP.

Another thing, you do not need the define OSC for the 629. It defaults to 4 MHZ.

DWayne

Jcee324
- 1st December 2004, 16:41
Hello

Well, the problem is that I can't erase the pic (or program it). Everytime I tries to erase or program it the programmer says that there isn't any pic connected.

Can the pic been codeprotected? Is there any way to remove a codeprotection if that is the case?

\Jonas
http://www.geocities.com/jcee324

Ingvar
- 1st December 2004, 16:43
What programmer and software are you using?

peterdeco1
- 1st December 2004, 17:35
Your code refers to Rb ports. The ports on 12F PIC's are GPIO ports.

Jcee324
- 1st December 2004, 17:56
Hello

The Rb and Ra ports I refer to is just that I have labeled my I/Os Ra and Rb, that has "nothing" with the program to do. The program workes fine now when I have added "CMCON=7". My problem now is that I can't reprogram or erase the pic. I have to reprogram it because I have to do some small changes in the program.

I am using Velleman's K8048 programmer and ProgPIC 2. I writes the code in MicroCode Studio Plus.

\Jonas
http://www.geocities.com/jcee324

Ingvar
- 2nd December 2004, 07:47
1. Make sure your powersupply can deliver a minimum of 13,5V when programming(erasing). 12V is too low for some pics.
2. Make sure that your COMport is not sharing IRQ with anything else.
3. Make sure your programmer works with another type pic like PIC16F627.
4. Try changing the programming speed(high,normal,low).
5. If you're doing ICSP, try programming the pic directly in the programmer with no ICSP cable attached.
6. Try another 12F629, just to make sure you didn't fry it on your first testrun.

/Ingvar

PS. Don't forget that SW5 should be in the "PROG" position. DS.

Jcee324
- 2nd December 2004, 12:20
I have tried all on your list Ingvar but I still have the same problem. I can drive the program that is on the pic but I can't reprogram or erase it. I have tried two pics, I could erase one of them useing the program "IC-prog" and then reprogram it with ProgPIC2 but not the other one. Is there anyway to reset/erase the pic "manually" by puting voltage on some pins? Or does anyone know another program that I could try?

\Jonas
http://www.geocities.com/jcee324

Ingvar
- 2nd December 2004, 13:44
Have you tried a different PC?

Dwayne
- 2nd December 2004, 14:26
Hello Jcee,

J>>I could erase one of them useing the program "IC-prog" and then reprogram it with ProgPIC2 but not the other one. Is there anyway to reset/erase the pic "manually" by puting voltage on some pins? Or does anyone know another program that I could try?<<

Whoa there my friend!!!! If you can erase one chip, but not the other...You could very well have a blown chip.

Dwayne

mister_e
- 2nd December 2004, 17:03
I Agree with Ingvar, maybe the supply line is unsufficient. Can you try.. if available LVP.

trying another PC can be also a solution, but try adding Buffer/driver(lets say opamp or voltage comparator) on DBs pins

that's really weird... is your supply line neat, without any noise, can 0.1uf ceramic and 10uF tantalum(47uF electrolytic) be add-on.

Jcee324
- 2nd December 2004, 17:10
Hello

But, if the chip was blown the program that is on it wouldn't work? Or am I wrong? I can run the program that is on the chip that I can't erase.

When I tries to erase/reprogram the chip with "ProgPIC2" the program answer that there are no chip connected. The same happens with the other chip (the one that workes) as soon as I programmed it. But after I erased it with "IC Prog" I could reprogram it again. And when I did reprogram it again the same message appears. I know that the chip is connected and that isn't loose.

I have also tried another power supply. It didn't work.

\Jonas
http://www.geocities.com/jcee324

mister_e
- 2nd December 2004, 17:27
for sur if the chip is blown, nothing else will give him the life back.

The only thing i can see, this chip is now in code protect... but not sure... it looks like so. In this case you ICPROG must return code protected device or something, but no... that's weird

is it in ICSP???

what about your schematic on board? is by any chance you can post it??

trying to help here :(

Dwayne
- 3rd December 2004, 19:28
Hello Jcee,

J>>But, if the chip was blown the program that is on it wouldn't work? Or am I wrong? I can run the program that is on the chip that I can't erase.<<

Not necessarily...the part that programs the chip may be blown...*if* that is the only chip it does it on. if your other chips work, then there is something else wrong. Voltages, ICSP pins not disconnected from circuit, or something...

I once blew a PWM on a 648A.... everything on the chip worked, except the PWM. <g>. So I converted that chip into a Serial LCD chip... <g>.

Dwayne

Jcee324
- 7th December 2004, 11:05
Hello

I have solved my problem!!! I build myself a JDM-programmer and programmed my 12F629 with it. It worked fine. So there is something with my program that does so the Velleman-programmer can't find the 12F629.

I want to thank everybody that has tried to help my with my problem. Thanks!

\Jonas
http://www.geocities.com/jcee324