PDA

View Full Version : 12F675 output dependency



Kristjan
- 4th May 2007, 22:43
I'm using PIC12F675. I have problems with digital outputs. It seems, that they are dependent to eachother.

DEFINE OSC 4 ' 4MHZ
ADCON0 =0 ' No analog inputs
ANSEL = 0
VRCON = 0
TRISIO = %00000000 ' Only digital outputs

loop:
GPIO.0 = 1 'LED 0
Pause 1000

GPIO.2 = 1 'LED 2
Pause 1000

GPIO.1 = 1 'LED 1
PAUSE 1000

goto loop
end

The outcome of this code is following:
LED 0 turns on, pause,
LED 0 turns off and LED 2 turns on, pause,
LED 1 turns on, pause,
LED 1 turns off and LED 0 turns on.
etc.
LED 2 remains all the time switched on. It seems, that GPIO.2 is somehow independent, and GPIO.0 and GPIO.1 are dependent. Why is it so? What I'm doing wrong? As much as I've read about it, all digital outputs should be independent.

Kristjan

mister_e
- 4th May 2007, 22:54
How about if you add CMCON=7 ?

sure i miss something around OPTION_REG.5=0 or something like that... i feel lazy today...

Kristjan
- 4th May 2007, 23:12
Yep. It works now :) Tnx.
Stupid question maybe, but why CMCON has to be 7 not 6 or 5? If I want to use also some analog inputs, then how CMCON has to be set? I'm also trying to find out the answer by myself.

mister_e
- 4th May 2007, 23:15
Look at section 7 (if my memory serves me well) of your datasheet (analog comparator section) there, should should find a table with the possible settings.

Analog comparator and analog to digital converter are two different animals...

Kristjan
- 5th May 2007, 00:44
Tnx. I got my problem solved :)