CrossRoads:
I'd simplify it:
Chip has max clock speed of 5 MHz, default for SPI is 4 MHz, Mode 0, MSB First will work fine if that's what your patchMatrix is set up with.
patchMatrix is defined, and selectively filled like this:
uint16_t patchMatrix[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// From and to are filled dynamically.
from = 10;
to = 5;
patchMatrix[to] += bit(from);
In the end, this is what patchMatrix could look like:
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 IN
S1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
S5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S7 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0
S8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S11 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
S12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
S13 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
S14 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
S15 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
OUT 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
Horizontal lines are a binary representation of the 16 integers stored in patchMatrix.
CrossRoads:
You seem to have an array of 16 ints to send out.
SPI.transfer sends 1 byte a time.
So:
for (x=0; x<16; x=x+1){
SPI.transfer(highByte(patchMatrix[x]); // or however you want to break up the int into bytes
SPI.transfer(lowByte(patchMatrix[x]);
}
// pulse PCLK LOW to parallel latches
digitalWrite (PCLK, LOW);
digitalWrite (PCLK, HIGH);
Cool! PCLK == SCK, or pin 13 on my UNO? And do I have to iterate patchMatrix in reverse?