Did you declare X VAR BYTE? Should work fine otherwise. What error do you get?
Did you declare X VAR BYTE? Should work fine otherwise. What error do you get?
Here is a program I posted some time ago. It can be used as an example to do what you are trying to do.
http://www.picbasic.co.uk/forum/show...highlight=port
Charles Linquist
Thanks Charles, I haven't had time to run a test but maybe I've spotted my problem whilst checking your code.
IF PortValue = 4 THEN
HSEROUT [10,13,"Port A4 is Open Collector!",13,10]
ENDIF
ADCON1 = $FF
TRISA.0(PortValue)= 0 'Make it an output
PauseUs 20
PORTA.0(PortValue) = 0 'Write a '0'
GOTO StateCheck
ENDIF
My understanding, according to the code, is that I should use round brackets not square brackets as I misunderstood? JEC's code to show???? I'll try and see if it works![]()
What port and chip are you using?
Have you shut the ADC off if the port has one.
Dave
Always wear safety glasses while programming.
I'm using mainly 16f628a's or a spare f84a I found lying around...all been tested and humming nicely.
With the code for 16f628a I am setting porta.4 to standard i/o with CMCON = 7 ... but I tested with ports b 1 through 5 earlier when I got the compiler error.
Am I right about the brackets? (round vs square)??
It works with [] or () for the bit index variable, but the high & low commands won't work with a variable bit index.
For bit indexing port pins you need to assign a 0 or 1 to the pin like this;
Code:Main: for x = 0 to 7 portb.0[x] = 1 pauseus 200 portb.0[x] = 0 pauseus 200 next GOTO Main
If you are using LEDs to see what is happening you may want to change
PAUSEUS
to
PAUSE
in the Bruce's code.
Dave
Always wear safety glasses while programming.
Bookmarks