16 of 172
ZBasic Language Reference 9 ZX Microcontroller Family The <pin> element specifies the pin to be configured. The first way to specify the pin to configure is to use the word Pin followed immediately by a physical pin number, e.g. Pin20. Of course, the set of pin numbers that can be specified in this way depends on the ZX processor that you are using. For example, for the 24-pin ZX devices the allowable values are Pin5 through Pin20 as well as Pin25, Pin26 and Pin27. The second way to specify the pin to be configured is to give the port letter and a bit number of the port with a period separating them, e.g. C.0. The advantage of the second method is that it is largely independent of the ZX processor that you’re using. The <pin-state> element may be one of the entries in the table below: Pin Configuration Values Pin State Meaning zxInputTriState The pin should be a tri-state input (pull-up disabled). zxInputPullUp The pin should be an input with the pull-up enabled. zxOutputLow The pin should be an output set to logic zero. zxOutputHigh The pin should be an output set to logic one. Alternatively, for compatibility with the Option Port directive, the <pin-state> element may be a quoted string containing a single character T, P, 0 or ¹ corresponding to the entries in the table above. For convenience when using the 24-pin ZX devices, RedLED and GreenLED are allowed as synonyms for Pin25 and Pin26 respectively. When using these synonyms the <pin-state> must be specified as On or Off. By default, all pins are configured to be inputs with the pullup disabled. Examples Option Pin5 zxOutputLow ' make pin 5 an output at logic zero Option Pin20 "T" ' make pin 20 a tri-state input Option C.0 zxOutputHigh ' make bit 0 of Port C an output at logic one Option RedLED On ' turn on the red LED Option <port> Option <port> <config-string> This option directive provides a way to configure an entire I/O port at once instead of doing so pin by pin. For each bit of the port being configured to be an input, you can further specify that whether or not the pull-up resistor is enabled. For each bit of the port being configured to be an output, you can further specify the logic level that you want to be output. This option directive may only appear in the first module compiled - usually the one containing the Main() subroutine. The allowable values for the <port> element are PortA, PortB, PortC, etc. Note, however, that PortB and PortD will rarely be used with the 24 pin ZX devices since the many of the pins of those ports are not directly available. The <config-string> element must be a series of characters, enclosed in quote marks, which specify for each bit one of four configuration states. The allowable configuration characters are described in the table below. The <config-string> must contain exactly 8 configuration characters, the leftmost of which corresponds to the most significant bit of the port and the rightmost of which corresponds to the least significant bit of the port. Certain bits of PortB and PortD have dedicated uses on some ZX devices that require a specific configuration. Due to this requirement, those bits are protected from being changed by user-specified configuration. By default, all bits are configured to be inputs with the pullup disabled except for the special purpose bits.