PDA

View Full Version : GP3 Funtion on PIC10f202



kessral
- 5th March 2009, 21:44
Hi all,
I am having problems getting GP3 to function as input only in a PIC10f202. Just for testing purposes I am trying to very simply blink and LED once per second on GP0 and throw in an extra pulse (pulse twice per second) when GP3 reads a low on input.

Here is my code:

trisio.3 = 0
loop:

high gpio.0
pause 100
low gpio.0
pause 500

if gpio.3 = 0 then
high gpio.0
pause 100
low gpio.0
endif

pause 500

goto loop

It is currently pulsing twice per second, and the chip ceases to work when I make GP3 low by pulling it down to ground.

I am using MPLAB IDE v7.11

Are there any obvious settings I have missed?

mackrackit
- 6th March 2009, 04:28
In the config settings turn MCLR or MCLRE, which ever that chip has to OFF.

Acetronics2
- 6th March 2009, 12:25
I am using MPLAB IDE v7.11

Are there any obvious settings I have missed?

Hi,

Yesss ... May be update to MPLAB v8.15 !!! ( CAUTION !!! NOT 8.20 - see Melab's site )

Alain

kessral
- 6th March 2009, 14:50
In the config settings turn MCLR or MCLRE, which ever that chip has to OFF.

In Configuration Bits "Master Clear Enable" is set to "Function as GP3" already, sorry forgot to mention that :(

Attempting Upgrade to MPLAB IDE v8.15 now :)

Acetronics2
- 6th March 2009, 15:03
Hi, Kessral

The surprising thing is you have configured GPIO.3 as an output ( trisio.3 = 0 ), and you intend to read it's state ...

Moreover, What is ... very annoying is you directly tie an output to ground or VCC ...

Not so good, yeah ...

hope you didn't fry it ...

always use a series resistor ( 1k ) whan you tie a pin to supply rails ...

Alain

PS : at the next one like this one, your surname will turn into " Casserole" ... lol.

kessral
- 6th March 2009, 15:18
I upgraded to v8.15 and same problem still exists.

on the PIC10f series GP3 is input or MCLR only and can never be an output. Default setting for GP3 on TRISIO would be 1, which is MCLR so I would assume that setting it to 0 would make it the only other setting it supports (Input only) maybe I am wrong, but I only placed that in the code after trying other methods.

I do use a resistor (at least 1k but usually much more) to pull GP3 to ground to send in a low, but at that point the chip just draws current as if in normal operation but all output functions cease (as in the LED no longer blinks and no outputs from GP0 exist)

This is telling me that GP3 is never actually getting set to input only but is staying as MCLR.. I have tried in the past to no avail, I am basically starting fresh with it now and hoping for help lol

mackrackit
- 6th March 2009, 23:52
In Configuration Bits "Master Clear Enable" is set to "Function as GP3" already, sorry forgot to mention that :(
)
Not sure where you are setting the config? You have some program that is doing it for you?
You will need to modify the *.inc file in the PBP directory to set the configs correctly.
This thread may help explain it. It talks about setting the configs in code space and what to do to make it happen.

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

And like Alan pointed out. TRIS for this application and pin should be 1.

kessral
- 10th March 2009, 19:49
Oh thank you! Don't know how I missed all this before but after some headache and commenting out 2 lines in the .INC file it works great! :D