PDA

View Full Version : 12C671 - GP3 problem



financecatalyst
- 17th March 2010, 08:19
Hi, I am having problems with GP3 of my 12C671. I am trying to use it as an input along with others (GP0,1,2,...,4). MCLR is off. All are held high with 10K, but pressing GP3 low, does not result in PIC performing accordingly.
Any ideas please as how I can use this pin properly? Thanks

mackrackit
- 17th March 2010, 10:35
Does your config look something like this?


__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

financecatalyst
- 17th March 2010, 10:39
Does your config look something like this?


__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF


It is:
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_ALL

Acetronics2
- 17th March 2010, 10:56
Hi, Finance

could we see your config and declare stubb ???

better, whole PBP program if possible ?

Many, many reasons possible .... and crystal ball saturated.

Alain

financecatalyst
- 17th March 2010, 11:03
DEFINE NO_CLRWDT
DEFINE OSC 4
Define OSCCAL_1K 1
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_ALL
'// For PIC12C671
include "modedefs.bas"

'// Define variables
ToTx VAR GPIO.0
PAUSE 30
'// OSCCAL=0
TRISIO = %111110
OPTION_REG = %10000000
ToTx = 0
INTCON=0
ADCON0.0=0
ADCON1=7

send:
if gpio.1=0 then
serout ToTx,N2400,["G0"]
Low ToTx
pause 10
endif

if gpio.2=0 then
serout ToTx,N2400,["G1"]
Low ToTx
pause 10
endif

if gpio.3=0 then
serout ToTx,N2400,["G3"]
Low ToTx
pause 10
endif

if gpio.4=0 then
serout ToTx,N2400,["G5"]
Low ToTx
pause 10
endif

goto send
end

Acetronics2
- 17th March 2010, 11:19
re,

1) did you try a simple pin test ??? just to verify pin is still alive ???

2) did you verify your 10k is Ok ??? ( logic 1 on pin when nothing done )

Also, Did you try enabling the CLR Watchdog ??? ...

Do all '671 react like this ???

Alain

financecatalyst
- 17th March 2010, 11:36
Hi, for some reason when I check the voltage on all pins, every pin except GP3 has 5V, whereas I don't know why GP3 is showing only 0.5V. They all are held high (5V) with 10K.

I also tried with 1K then 470Ohm, but voltage on GP3 is not going above 0.8V after that. Also just want to add that, my circuit is in such a way that it only gets power when a button is pressed. Buttons bring in the -Ve supply to the system from a 12V battery, also the -Ve goes to the 7805 so PIC gets its 5V as well.

Acetronics2
- 17th March 2010, 12:20
Hi, for some reason when I check the voltage on all pins, every pin except GP3 has 5V, whereas I don't know why GP3 is showing only 0.5V. They all are held high (5V) with 10K.

.

That looks much like a fried pin ... as it is an " input only " pin ...
You have to take care of these pins ... cause there's no clamping diode to VDD : must be treated as a full CMOS input with antistatic discharges handling precautions.

Alain

financecatalyst
- 29th March 2010, 10:39
Hi, I now got a chance to come back to this problem of my pic. Apologies for the delay in updating you.
OK, I have programmed another 12C671 taking care of static discharges. Now the voltage part on GP3 is working fine. It is pulled high at 5V. But making it low does not initiate the required serout signal.
Is there something I am missing in the code to make proper use of GP3 as an input?
Thanks

financecatalyst
- 30th March 2010, 18:21
Anyone there?
Please help

mackrackit
- 30th March 2010, 21:14
I never responded because I do not see where the problem is.

Have you changed the code or configs any? If you did re-post.
Did you try clearing the WDT like Alan suggested?

Can you post a schematic or a picture of your setup?

financecatalyst
- 31st March 2010, 06:03
Hi, thanks for the reply.
I did changed the config and enabled the WDT. The code looks like this now:


DEFINE OSC 4
Define OSCCAL_1K 1
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CP_ALL
'// For PIC12C671
include "modedefs.bas"

'// Define variables
ToTx VAR GPIO.0
PAUSE 30
'// OSCCAL=0
TRISIO = %111110
OPTION_REG = %10001000
ToTx = 0
INTCON=0
ADCON0.0=0
ADCON1=7

send:
if gpio.1=0 then
serout ToTx,N2400,["G0"]
Low ToTx
pause 10
endif

if gpio.2=0 then
serout ToTx,N2400,["G1"]
Low ToTx
pause 10
endif

if gpio.3=0 then
serout ToTx,N2400,["G3"]
Low ToTx
pause 10
endif

if gpio.4=0 then
serout ToTx,N2400,["G4"]
Low ToTx
pause 10
endif

goto send
end

My circuit only gets power when any button is pressed. I can try to scan the paper after drawing the circuit or try to find a software over the net if you think the circuit could be the culprit.
But I would like to add that rest all the buttons are working fine, so I believe the circuit is ok, GP3 is connected the same way as all other pins. Even the voltage on that pin behaves the same way as on any other pin under same circumstances but no DATA OUTPUT is there.

mackrackit
- 31st March 2010, 06:50
Can you try making GPIO3 active high?

financecatalyst
- 31st March 2010, 07:18
Yes I can do it to check but I really need to find an answer to make it work Active Low. I will reply with an update with Active High.

financecatalyst
- 31st March 2010, 13:40
I tried one method in which I gave continues supply to the PIC for 5v. All pins work fine as expected (Active Low).
The problem of GP3 only strikes when circuit gets power only when button is pressed and pin is made low.

malc-c
- 31st March 2010, 18:40
Not sure about the 12C chip, but on 12F series GPIO3 is the MCLR pin and what could be happening is by grounding this you are resetting the PIC - there is a way of disabling the reset function on the 12F series, so you might need to do the same on the 12C chip

financecatalyst
- 31st March 2010, 19:09
Not sure about the 12C chip, but on 12F series GPIO3 is the MCLR pin and what could be happening is by grounding this you are resetting the PIC - there is a way of disabling the reset function on the 12F series, so you might need to do the same on the 12C chip

Hi, I already have disabled the MCLR - (in Config). I also mentioned in the post above that PIC works fine when 5V supply is continues. Thanks

mackrackit
- 31st March 2010, 21:18
PIC works fine when 5V supply is continues.
What exactly do you mean?

financecatalyst
- 1st April 2010, 06:44
When I put 5V continues supply i.e. system already gets +ve & -Ve 5V and does not depend on button press for -Ve. Then lowering GP3 does result in serout data.

In other words, pic gets its 5V continues and all pins pulled high with 10K. Lowering any pin results in serout data.

malc-c
- 1st April 2010, 07:25
i.e. system already gets +ve & -Ve 5V and does not depend on button press for -Ve.

Are you applying 10V across the supply pins ? - I thought most pics will only work on 5V (ie +5v and 0V supply lines)

financecatalyst
- 1st April 2010, 07:32
No, it is 5V only. i.e. +5V & 0V.

Acetronics2
- 1st April 2010, 08:14
Hi, FC



My circuit only gets power when any button is pressed.


Reading that , ... I think you didn't show or tell us everything :

OR the code shown only is a part of ...

OR you should show the Hardware side ...

no way for us to help further not knowing what you did and how you did it ...

Alain

financecatalyst
- 1st April 2010, 12:36
Hi, I have attached the schematic and this is the complete code I have shown here. Hope to find a solution soon.

mackrackit
- 1st April 2010, 13:30
The way I read this, from the data sheet


Most other registers are reset to a “reset
state” on Power-on Reset (POR), MCLR Reset, WDT
Reset, and MCLR Reset during SLEEP
Every time you press the GPIO.3 button the chip will go into a continuous reset.
The chip never gets to read the configuration to see that MCLR is turned off.

malc-c
- 1st April 2010, 13:52
Hi, I have attached the schematic

Comments:

1) - There are no smoothing capacitors either side of the regulator - what are you using to provide the 12v supply. If it's simply a bridge rectifier off a transformer then the supply will need smootthing.

2) - I assume the diodes are LEDS ? If so then you would be better off putting them in series with the resistors rather than in parallel.

3) - If they are not LEDS, then try removing them from the circuit, there may be some reverse bias or something causing the current to flow and possibly short out the supply ?

As Dave has mentioned - It does sound as if you are constantly resetting the chip before it configures itself.

aratti
- 1st April 2010, 15:03
With reference to your schematic, I am sure you have mistaken in drawing it, while the hardware is correctly wired, otherwise you will short the 12 Volts as soon as you connect it to the circuit. ( see the snap posted and compare it with your circuit)

As far as the code is concerned, I would place a delay below the label send




send:
PAUSE 10
if gpio.1=0 then
serout ToTx,N2400,["G0"]
Low ToTx
pause 10
endif



Al.

malc-c
- 1st April 2010, 18:40
With reference to your schematic, I am sure you have mistaken in drawing it, while the hardware is correctly wired, otherwise you will short the 12 Volts as soon as you connect it to the circuit. ( see the snap posted and compare it with your circuit)

:eek: how did I miss that ! I was just getting confused with all the diodes !

Mind you I guess it was just a miss-print, otherwise there would of been a nice bang when he powered it up for the first time :)

Bruce
- 1st April 2010, 18:53
Have you tried this with _PWRTE_OFF..?

financecatalyst
- 1st April 2010, 19:37
Aratti, your eye for detail is good. I made mistake in drawing it. Thanks for correcting it. I tried with a pause of 50mS before going to label send, but it didn't worked.

Malcom, Mackrackit, thanks for pointing out the smoothing capacitors and resetting problem.

I tried the smoothing capacitors at in & out of 78L05. At one configuration of 47uF at input & 22uF at output, everything works fine with one particular 12V battery I have but does not work when I change the battery. That particular battery had a voltage of 12.96V, I changed it, the other battery had 12.16V. I tried many times with with 12.96V, it works fine all the time but not when I change the battery. I tried different values of capacitors and the results were very strange, at few other configurations of the capacitors, it even affected other pins as well. All these trial were done with 12.96V battery.

After seeing these results, I believe the problem is related to correct configuration of capacitors. Any comments?

I would like to ask two things:
1) Is there any formula or way to find out the correct capacitor values at in & out of 78L05?

2) Is there any way around the resetting problem of GP3, I would like to try it as well to see if that is the root cause of this problem?

Bruce, thanks for the reply, I will try with _PWRTE_OFF and update this thread.

Thanks everyone for trying to help.

aratti
- 1st April 2010, 20:03
1) Is there any formula or way to find out the correct capacitor values at in & out of 78L05?

No! Simple rule of thumb. place 220 nF at the input and 100 nF at the output, the closest possible to the regulator terminal.

Al.

mackrackit
- 1st April 2010, 20:15
If the _PWRTE_OFF idea does not work then I think you know the problem is in resetting as you mentioned if the chip has continuous power it works.

So you could add something to the GPIO.3 button to power the chip first, before the actual button is pressed. No magic but more circuits.

financecatalyst
- 2nd April 2010, 05:49
I tried with 220nF at input & 100nF at output of 78L05. Changed the config a little to try this code on 12F635 which I happen to have quiet a lot. This way I can save few 12C671. The circuit remains the same.

_PWRTE_ON or OFF is not making any difference.

The problem is stuck on GP4 now. GP 0,1,2,3 are working fine.

Archangel
- 2nd April 2010, 05:50
Hello F.C.
What voltage do you read on GP.3 when the switch is pressed? I ask because it is an input with schmitt Trigger input, perhaps the voltage is not low enough to switch it.

financecatalyst
- 2nd April 2010, 05:54
Hello F.C.
What voltage do you read on GP.3 when the switch is pressed? I ask because it is the only input with schmitt Trigger input, perhaps the voltage is not low enough to switch it.

I read 0V when switch is pressed.

Archangel
- 2nd April 2010, 09:38
I would look for anything (registers) that sets different on POR as opposed to a cold boot, I have not looked, does this chip have ANSELH ? I just gotta hunch it is some little analog something . . .

financecatalyst
- 2nd April 2010, 09:57
Does this chip have ANSELH ?
No, I have checked the datasheet again for 12C671. Thanks

malc-c
- 2nd April 2010, 12:44
It seems strange that you stated it works fine with one battery but not another. Is there any reason for using 12v, which will mean the regulator will need to drop 7v which would generate a fair amount of heat. I would make a simple supply for testing of 6v transformer, rectifier, and a couple of 2500uF electrolytic capacitors (or use one of those DC plug type power supplies, and do away with the rectifier ), Then use the 100 / 200 nf caps either side of the regulator. It's also worth mounting the regulator on a heatsink. This should give you a very stable, smooth 5V dc supply for testing.