228 of 286
214 ShiftIn Type Function returning Byte Invocation ShiftIn(dataPin, clkPin, bitCnt) Parameter Method Type Description dataPin ByVal Byte The pin used to input data. clkPin ByVal Byte The pin used to output a clocking signal. bitCnt ByVal Byte The number of bits to read in (1 to 8). Discussion This function can be used to input data from a synchronous serial device like a shift register. The pin specified for input will be made an input 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, then the clock line will be pulsed by changing its logic level twice. The data line will be sampled approximately 2 CPU clock cycles after the leading edge of the clock pulse. With a 14.7456MHz CPU clock, this equates to about 135nS after the leading edge. The returned value consists of the data bits read with the bit first read in the most significant bit position. This is referred to as MSB first. If fewer than 8 bits are read, the low order bits will be zero. Resource Usage This subroutine uses the I/O Timer. If the I/O Timer is already in use, the function returns immediately and the return value is zero. 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 ShiftInEx, ShiftOut, ShiftOutEx