PORT(start, nbr) = value
Set a number of I/O consecutive pins simultaneously (ie, with one command).
‘start’ is an I/O pin number and the lowest bit in ‘value’ (bit 0) will be used to set that pin. Bit 1 will be used to set the pin ‘start’ plus 1, bit 2 will set pin ‘start’+2 and so on for
‘nbr’ number of bits. The I/O pins used must be numbered consecutively and configured as outputs before this command is used.
For example;
PORT(4, 8) = &B10000011
will set eight consecutive I/O pins starting with pin 4. Pins 4, 5 and 12 will be set high while 6 to 11 will be set to a low.
If the range of pins specified by the PORT command and function includes pin(s) that are not valid or not properly configured an error will not be raised. Instead the pin will be ignored or return a zero bit.
PORT(start, nbr)
Returns the value of a number of consecutive I/O pins in one operation.
‘start’ is an I/O pin number and its value will be returned as bit 0. ‘start’+1 will be returned as bit 1, ‘start’+2 will be returned as bit 2, and so on for ‘nbr’ number of bits. The I/O pins used must be numbered consecutively and configured as inputs before this command is used.
This command can be used to conveniently communicate with parallel devices like LCD displays. Any number of I/O pins (and therefore bits) can be used from 1 pin up to 23 pins.
If the range of pins specified by the PORT command and function includes pin(s) that are not valid or not properly configured an error will not be raised. Instead the pin will be ignored or return a zero bit.
See also:
PIN
SETPIN
Leave a Reply