How to make port-c's into inputs

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

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 :slight_smile:

How does the pic…

How does the picaxe know the difference between portc 6 and regular input 6 by using "if pin6=…"?

-Or is pin6 and input6 the difference?

–thanks for the serial/ i2c interrupt info

 

Please just forget the

Please just forget the portc, OK?

There is no portc.

Vanished.

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)

 

Damnit !!!

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!

 

DAMN YOU, PORT-C… …DAMN YOUUUUUuuuuuuuu…

----Thanks for the i2c stuff
The setint flag stuff will help, though. --Thanks frits

Look, Pal: PORTC IS AN INPUT

Look, Pal: PORTC IS AN INPUT MADE AN OUTPUT. AND SO IF YOU WANT TO USE IT AS INPUT, JUST OMIT THE FREAKIN PORTC-COMMAND!!

How hard can that Be?

FORGET THE PORTC!! IT IS AN INPUT PORT!!

Thanks Obama!
Thanks Obama!

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…

Obama…

Obama could change portc’s into inputs! He would write the code himself!

 

The black chill pill.
:slight_smile:

He can also walk on water
He can also walk on water and make useless PCBs whole again!

Yes he can!
Yes he can!