This is very simple, I have 2 picaxes talking to each other. I am already using the int command for another reason. Right now, I need to set up a handshake before one pic tries to send a serial command to the other and to be sure the 2 pics are not trying to send to I2C at the same time. I have portc 5 going to portc 5 and portc 6 going to portc 6. one 5 is an input, one 5 is an output. One 6 is an input, one 6 is an output. I have the outputs down: High portc 5 and high portc 6.
Question.
What is the command to allow a portc pin to become an input?
If this were a standard input, the command would be: if pin6 = 1 then...
How do I write the above, but using a portc as an input?
First; The headline is like "how to use a hammer as a hammer". "Portc IS an input!
Second; You should really have a look at the interrupts; There is a flag for incomming i2c & serial.
Answer:
Q: What is the command to allow a portc pin to become an input?
A: Nothing, just do not write portc, use the input port as in the manual for digital input ports…
Q: If this were a standard input, the command would be: if pin6 = 1 then…
A: Yes, that is it.
Q: How do I write the above, but using a portc as an input?
By writing the above, you ARE using "portc" as an input. The command Portc" is ONLY to be used if you want to use this INPUT port as an OUTPUT port. Whish you are not, so forget the command "portc", and use the input port as it is to be used
You have input ports and output ports. And analouge input ports.
That is all.
One day, when you needthese inputports to be output ports, that day - seperated from today - you will look up the command / description"portc". You will find that this will enable you to use your inputs as outputs to some extend.
Bonus info:
Look at page 11 in the Picaxe 2 manual. You are looking for this extremely valuable part:
flag5 hserflag hserial background receive has occurred flag6 hi2cflag hi2c write has occurred (slave mode)
This is the second time the portc’s have screwed me!! The first was when I had everything soldered before I knew you can’t run a servo command through the port-c. NOW, I have everything soldered and a port-c can’t be an input! ARRRGGGGG!
Hardware Handshake? Why introduce a hardware handshake? SUrely it would be better to have one pic as the "bus master" and the other as the slave? Let I2C do the handshaking for you. There is even protocol support for multiple bus masters…