Devices & Components
Arduino Uno Rev3
Resistor 220 ohm
LED (generic)
Breadboard (generic)
Shift Register- Serial to Parallel
Jumper wires (generic)
Software & Tools
Arduino IDE
Project description
Code
Example of bank interleaving
c_cpp
Example of bank interleaving in which we demonstrate the use of a single physical SIPO IC software configured as two virtual banks but operating on the same 3 wire interface.
1// 2// Tutorial 5 - use of ez_SPI8 library, 3// Demonstration of SIPO bank interleaving - 8 x physical SIPOs 4// each mapped to an individual bank but with the same 3-wire digital 5// pin microcontroller interface. 6// 7// The sketch sets up each single SIPO bank with a different binary 8bit 8// (8 pin) pattern which is then xferred to the physical single SIPO IC. 9// The sketch mimics the strobe sketch by using bank interleaving. 10// To note is the small amount of SIPO8 library code that is used. 11// 12// Ron D Bentley, Stafford, UK 13// April 2021 14// 15// This example and code is in the public domain and 16// may be used without restriction and without warranty. 17// 18 19#include <ez_SIPO8_lib.h> 20 21int bank_id; 22 23#define Num_SIPOs 8 24#define Num_timers 0 25 26SIPO8 my_SIPOs(Num_SIPOs, Num_timers); // initiate the class for the tutorial 27 28uint8_t bank_ids[Num_SIPOs]; // one bank_id per SIPO bank 29uint8_t bank; 30 31void setup() { 32 Serial.begin(9600); 33 // create banks of 1 x SIPO, all of same 3-wire interface and initialise 34 // with each strobe pattern - 0b00000001, 0b00000010, 0b00000100, etc. 35 // create_bank params are: data pin, clock pin, latch pin, number of SIPOs this bank 36 for (bank = 0; bank < Num_SIPOs; bank++) { 37 bank_ids[bank] = my_SIPOs.create_bank(8, 10, 9, 1); 38 if (bank_ids[bank] == create_bank_failure) { 39 Serial.println(F("failed to create bank")); 40 Serial.flush(); 41 exit(0); 42 } 43 // now set up the strobe patterns in the bank's single SIPO, relative SIPO address is 0 44 // sliding pattern of 1's starting at 0b00000001 45 my_SIPOs.set_bank_SIPO(bank_ids[bank], 0, 1 << bank); // set up this bank's strobe pattern 46 } 47 // print the bank data and pin statuses for confirmation/inspection 48 my_SIPOs.print_SIPO_data(); 49 my_SIPOs.print_pin_statuses(); 50} 51 52void loop() { 53 // scroll through every SIPO bank (interleave) and xfer the bank's pins 54 // according to the direction for shift out. 55 bool msb_or_lsb = MSBFIRST; // starting direction 56 do { 57 for (bank = 0; bank < Num_SIPOs; bank++) { 58 my_SIPOs.xfer_bank(bank, msb_or_lsb); // xfer out this bank's SIPO pins 59 delay(50); 60 } 61 msb_or_lsb = !msb_or_lsb; // switch direction 62 } while (true); 63} 64
Downloadable files
Single SIPO Shift Register, wiring diagram
Used throughout the tutorials
Single SIPO Shift Register, wiring diagram

Single SIPO Shift Register, wiring diagram
Used throughout the tutorials
Single SIPO Shift Register, wiring diagram

Comments
Only logged in users can leave comments