You need to do a little more than that...
Datasheet is your friend... use it...
First... TRISIO will set INPUT (1) or OUTPUT (0)... so...
TRISIO=%01111 ' example will set GPIO.5 as OUTPUT and all the others as INPUT...
then always check for COMPARATORS... now GPIO.5 doesn't have any, but if you are not going to use them, switch them OFF, because by the time you start playing with GPIO.0, GPIO.1 and GPIO.2, you'll be back on this forum asking us why they don't work... so add...
CMCON=%00000111 ' see Datasheet Section 6
Next check that you have your A/D's switched off... again, they don't affect GPIO.5, but if you are not going to use them, they can impact on the other GPIO's so disable the A/D with the instruction...
ANSEL=%00000000 ' see Datasheet section 7
Next GPIO.5 and GPIO.4 is where you normally connect your Xtal or Resonator... if you are going to use those pins for I/O then you probably want to enable the INTERNAL OSCILLATOR... so use the command (if you are using PBP's default PM Assembler)...
@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT ' System Clock Options (Internal)
Finally, if you want to use GPIO.3 as INPUT (rather than have to connect MCLR externally), then have the PIC handle MCLR internally for you with the setup...
@ DEVICE pic12F675, MCLR_OFF ' Master Clear Options (Internal)
A good set of CONFIGURATION SETUP's for playing with the 12F675 are...
Code:
'
' PIC Defines
' -----------
@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
' System Clock Options (Internal - GPIO.4 and GPIO.5 available for I/O)
@ DEVICE pic12F675, WDT_ON
' Watchdog Timer
@ DEVICE pic12F675, PWRT_ON
' Power-On Timer
@ DEVICE pic12F675, MCLR_OFF
' Master Clear Options (Internal - GPIO.3 available for INPUT)
@ DEVICE pic12F675, BOD_ON
' Brown-Out Detect
Your PIC's GPIO.5 should now be working with Gary's code... if it isn't, check you've not shorted GPIO.5 against the adjacent Vdd pin which could cause it to hold HIGH.
Bookmarks