Yes TRIS will work... but you need to use the according name as per the datasheet.... TRISIO will do the job as expected.
Sure the PBP handbook will not cover it. TRISIO, TRIS is not a PBP command, just a PIC register.
You could still use
INPUT GPIO.0
OUTPUT GPIO.1
and so on.
TRISIO= %00000001 ' set GPIO.0 as input, other to output... when possible (MCLR)
it's not a bad idea to set initial value to your PORT as well.
Don't forget, all i/o are set as input at POR.
try this one
Code:
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
@ DEVICE pic12F629, WDT_ON ; Watchdog Timer
@ DEVICE pic12F629, PWRT_ON ; Power-On Timer
@ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
@ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
@ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
@ DEVICE pic12F629, PROTECT_OFF
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1k
CMCON = 7
TRISIO = %00100000 ' port5 is an input
Button1 var gpio.5
Led1 var gpio.0
GPIO = 0 ' clear all outputs
PAUSE 50 ' internal OSC settle time... more than safe
main:
if button1 = 0 then ' if the button is pressed
pulsout Led1,10000
while Button1 = 0 : wend
pause 50
else
pulsout Led1,2000
endif
goto main
Bookmarks