IO operation

basically miscellaneous, if it doesn't fit another sub-forum enter it here, we might even promote it to its own sub-forum
Post Reply
basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

IO operation

Post by basicchip »

>this is not a bug as reported by a user

Code: Select all

Sub PulseOut (PinNumber as Integer, Length as Integer) 'Length in mS
 
 IO(PinNumber) = NOT(IO(PinNumber)) 'this reversal works
 WAIT(Length)
 IO(PinNumber) = NOT(IO(PinNumber)) 'this one does not.
End Sub
Why-

IO is more complex than just setting a pin.

IO (as the Help files state) sets the direction of the pin then sets the drive level.

so IO(x) = NOT(IO(x))

is converting a pin to an input reading it and then converting to an output and driving it

But during the conversion to an input you are no longer driving it. So you really want to do--

OUT(x) = NOT(IN(x))

As OUT just changes the drive level, and IN reads the pin value whether or not it is being driven (also in the Help files)



Post Reply