PDA

View Full Version : GPIO.2 of 12F509 doesn't work.



Peter Oors
- 5th April 2005, 20:21
At the first time of using the 12F509 instead of the 12F629 I discovered a problem.
@ device INTRC_OSC,MCLR_OFF
'cmcon=7 'for the 12F629 only
trisio=%001000
GPIO=%000000
GPIO=%110111
Pause 1000
GPIO=%000000
Stop

All 5 outputs of the 629 went high for 1 second.
The 509 GPIO.2 doesn't do anything, GPIO.0, 1, 4 and 5 went high for one second.
Both PIC's are tested on the same PCB.
What could be wrong or what do I do wrong?
I use PBP2.46, MPLab7.1 and PICStart Plus.

Melanie
- 5th April 2005, 21:08
Try this... and tell us if it works...



TRISIO=%00001000
Loop:
High GPIO.2
Pause 1000
Low GPIO.2
Pause 1000
Goto Loop

end

Peter Oors
- 5th April 2005, 22:38
Try this... and tell us if it works...



TRISIO=%00001000
Loop:
High GPIO.2
Pause 1000
Low GPIO.2
Pause 1000
Goto Loop

end


Hello Melanie,
I tried and: GPIO.2 stays low, GPIO.0 , 1 , 4 and 5 are high.
If I put GPIO=%00000000 after Trisio all outputs are low.
I took a new PIC509 and the same happens, very strange.
The 629 GPIO.2 works fine.....

Melanie
- 5th April 2005, 23:50
Datasheet, Datasheet, Datasheet!!!!!

Really.... you gotta get this tatooed in some prominent place...

Walk with me on this one...

GPIO.2 is also the T0CKI pin...

Table 6-1 on Page 34 Reference Note (3) at the bottom states "The TRIS of the T0CKI pin is over-ridden when T0CKS=1". There's also a great-big NOTE to this effect at the top of Page 22!

T0CKS is part of the OPTION REGISTER.

See Register 4-3 on Page 22 and cross-reference this with Table 7-3 (Reset Conditions) on Page 44... you will note that this register bit is set to '1' on Power-up, therefore TRISIO is over-ridden...

So set OPTION_REG.5=0 before your TRISIO statement.

Peter Oors
- 6th April 2005, 20:33
Thanks Melanie,

It's all working now.
Your explanation was very clear.
I understand now why it didn't work, but I couldn't find it out by myself.

Thanks a lot.