223 of 318
ZBasic System Library 213 ZX Microcontroller Family PutPin Type Subroutine Invocation PutPin(pin, mode) Parameter Method Type Description pin ByVal Byte The pin to configure. mode ByVal Byte The configuration mode (see below). Discussion This routine is used to configure a pin to be an input or an output or to effect a change in the output logic level. If the pin is configured as an input, it may be configured to be in “tri-state” mode or “pull-up” mode. If the pin is configured to be an output, the output level may be set to zero or 1. The table below gives the values for each of the possible modes. If an invalid mode is specified or an invalid pin is specified, the routine has no effect. Values for the mode Parameter Value Built-in Constant Description 0 zxOutputLow The pin is an output at logic zero. 1 zxOutputHigh The pin is an output at logic one. 2 zxInputTriState The pin is an input with the pull-up/pull-down resistors disabled. 3 zxInputPullUp The pin is an input with the pull-up resistor enabled. 4 zxOutputToggle Change the logic level of the output. 5 zxOutputPulse Pulse the output. 6 zxInputPullDown The pin is an input with the pull-down resistor enabled 7 zxInvertIO Input and output levels are inverted. 8 zxNormalIO Input and output levels are normal (non-inverted). Note that for modes 4 and 5 to be useful, the pin must have been previously set to be an output. Mode 4 (zxOutputToggle) will change the output to the opposite logic level. Mode 5 (zxOutputPulse) will change the output to the opposite level for a short period of time and then change it back to the original level. The duration of the pulse will be about 8 CPU cycles (approximately 0.5uS at 14.7456MHz). Modes 6, 7 and 8 are only supported on ZX devices based on the xmega CPU. Modes 7 and 8 are to be used in conjunction with the other modes (in separate calls, of course) to achieve the desired configuration. Example Call PutPin(12, zxOutputLow) ' pin 12 will be at logic zero Compatibility In BasicX compatibility mode, mode values higher than 3 are not supported. See Also GetPin