Hi,
I am using a picaxe 28x1 and I am developing new code like crazy. In one of my sub routines, I need to reconfigure one of the input pins (pin 7 in port C) to output mode. Then pull it low. Then wait a bit. Then make it high impedance again. That is to say, it must become an input again.
This code would do that:
down:
low portc 7 ' by bringing the pin low it automatically becomes an output pin
pause 1000 ' wait a moment
dirsc = %00000000 ' this blindly sets all pins to output mode
return
However, I do not want to set the input direction for ALL pins in portc, just the one I am using here. For all I know, other routines are making decisions about the other pins' directions. And I need my sub routine to respect that.
Now, if I would have all the direction bits for port C available in one byte (b13 for example), I could simply change the bit corresponding with my pin in that byte and use the byte instead of %00000000. Like this:
down:
low portc 7 ' by bringing the pin low it automatically becomes an output pin
pause 1000 ' wait a moment
b13 = dirsc ' this function does not exist in picaxe 28x1 basic 8-(
b13 = b13 AND %01111111 ' remember directions from all other pins, make bit 7 zero regardless
dirsc = b13 ' set the new situation to port C
return
The simulator proves this second code to be valid in an X2, but not in an X1. Who knows a way to get me what I want, without upgrading the chip?
(I checked; the command "input C.7" does also not work on an X1.)