260 of 318
ZBasic System Library 250 ZX Microcontroller Family ShiftOut Type Subroutine Invocation ShiftOut(dataPin, clkPin, bitCnt, val) Parameter Method Type Description dataPin ByVal Byte The pin used to output data. clkPin ByVal Byte The pin used to output a clocking signal. bitCnt ByVal Byte The number of bits to shift out (1 to 8). val ByVal Byte The value to shift out. Discussion This function can be used to output data to a synchronous serial device like a shift register. The pin specified for output will be made an output but the pin specified for the clock signal must already be an output and be at the desired initial logic level. For each of the number of bits specified, the data pin will be set to the state of the corresponding bit in the val parameter beginning with the most significant bit first. Then the clock line will be pulsed by changing its logic level twice. Data is shifted out MSB first. If a data width of fewer than 8 data bits is specified, the data must be positioned in the most significant bits of the value and the state of the remaining low order bits in the value is of no consequence. Resource Usage This subroutine uses the I/O Timer. If the I/O Timer is already in use, the subroutine returns immediately. No other use of this resource should be attempted while the shifting is in progress. Interrupts are disabled during the shifting process. However, RTC ticks are accumulated during the shifting process so the RTC should not lose time. Compatibility For compatibility with I2C/TWI devices the clock rate is approximately 200kHz with Register.TimerSpeed1 at its default value of 1. If the value of Register.TimerSpeed1 is changed, the bit rate will be slower. See Also ShiftIn, ShiftInEx, ShiftOutEx