SCEA117 July 2022 SN74HCS164 , SN74HCS164-Q1 , SN74HCS165 , SN74HCS165-Q1 , SN74HCS595 , SN74HCS595-Q1
The software required to control a set of shift registers is relatively simple. Figure 5 provides a generic flowchart that can be used for producing code in any language and with any hardware for GPIO control of shift registers. In this flowchart, there are two loops. The outer loop, shown in blue, repeats for every shift register in the chain. The inner loop, shown in red, repeats for every bit within a shift register. Typically, the number of bits is eight, however it can vary.
The [Read or write bit ‘j’] block is the most important and the most difficult to implement. Please see the example code shown in code example 1 for an approach using an MCU’s built-in SPI module, and the example shown in code example 2 for a direct GPIO control approach.
There is also code provided for the Example Design – Daisy Chain 128 Shift Registers.