PDA

View Full Version : Trouble with PIC12F683 - GP0 GP1 as inputs



erice1984
- 30th March 2009, 03:10
Having trouble gettin the PIC to understand that I want GPIO.0 and GPIO.1 set as inputs, when receiving a 5v signal on either port to execute accordingly. Instead it sits there and does nothing, I think it is in the registers.

define OSC 4 'Set oscillator (clk) to 4MHz
GPIO = %00001000 'High/Low
TRISIO = %00101011 'Input/Output
ANSEL = %00110000
CMCON0 = %00000000
CCP1CON = %00000000
VRCON = %00000000

'ADCON0 = %00000000
'OPTION_REG = %0
'WPU = %00000011

only common points these two pins share is serial programmer, and comparator inputs, and convienently the comparator ouput pin as an output works just fine!

Darrel Taylor
- 30th March 2009, 03:51
CMCON0 = %00000000
... only common points these two pins share is serial programmer, and comparator inputs, and convienently the comparator ouput pin as an output works just fine!
Exactly as it should.

Comparator mode 0 has both GP0 and GP1 as ANALOG inputs, with GP2/COUT as DIGITAL.
Configurations can be seen in FIGURE 8-3 COMPARATOR I/O OPERATING MODES.

The configuration you want is CMCON0 = %00000111 ... (ALL DIGITAL).
<br>

erice1984
- 30th March 2009, 03:57
sorry, I didnt make my question clear enough.

I don't want to use the comparator. I just want them GP0, GP1 as inputs, and GP2 stays as output to flash a simple LED.

Darrel Taylor
- 30th March 2009, 04:00
OR ... maybe I wasn't clear ...

Cause that's what I meant too.
<br>

erice1984
- 30th March 2009, 04:05
lol, I test it. and it just goes crazy and nothing else seems to work.

I dont know, maybe I should just play with it. I wish they had a register that would DISABLE it completely, not make me fumble with options until I find the right combination

erice1984
- 30th March 2009, 04:21
nevermind, you were right, I was wrong.

I switched from my program I had working and everything and went to my 'trusted' test program, forgot about using the MCLR pin as an input, saw it, corrected it.

The settings you proposed work as we both thought they should have.

Thanks for the help :)

Darrel Taylor
- 30th March 2009, 04:32
There's one you won't forget next time. :)

Cheers!
<br>