user70642: when I try the following code the SPI works correctly (see oscilloscope plot)
#include <SPI.h>

void setup() {
  SPI.begin();
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  SPI.transfer(a, 4);
  SPI.endTransaction();
  delay(10);
}


However when I move the array declaration to the a global it doesn't work any more. (see next oscilloscope plot) Why is this?
#include <SPI.h>

byte a[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  SPI.transfer(a, 4);
  SPI.endTransaction();
  delay(10);
}



user37523: When you call SPI.transfer(a, 4);, any "received data" is stored in your byte array, a[]. The original data is overwritten.
If you print out the contents of the array before and after the function call to SPI.transfer(), you will see in the serial monitor what is happening to your array contents.
Here are 2 test sketches to illustrate the difference between the array with a global scope, VS the one with a static scope.
Global Scope
// Sketch uses 2344 bytes (7%) of program storage space.
// Global variables use 193 bytes (9%) of dynamic memory. 
#include <SPI.h>

byte a[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}

Static Scope
// Sketch uses 2410 bytes (7%) of program storage space.
// Global variables use 193 bytes (9%) of dynamic memory. 
#include <SPI.h>

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}


The following sketch should solve the problem. Using the const keword before the declaration of the b[] array is optional.
// Sketch uses 2436 bytes (7%) of program storage space.
// Global variables use 197 bytes (9%) of dynamic memory. 
#include <SPI.h>
const byte b[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  memcpy(a, b, sizeof(b));
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}


One last edit. The compile size can be reduced by 66 bytes thanks to the static keyword.
// Sketch uses 2370 bytes (7%) of program storage space.
// Global variables use 197 bytes (9%) of dynamic memory. 
#include <SPI.h>
const byte b[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  static byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  memcpy(a, b, sizeof(b));
  for(int i = 0; i < 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}

For more information, see: Arduino.cc

70642: <p>when I try the following code the SPI works correctly (see oscilloscope plot)</p>
<pre><code>#include &lt;SPI.h&gt;

void setup() {
  SPI.begin();
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  SPI.transfer(a, 4);
  SPI.endTransaction();
  delay(10);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/MmI1n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MmI1n.png" alt="enter image description here" /></a></p>
<p>However when I move the array declaration to the a global it doesn't work any more. (see next oscilloscope plot) Why is this?</p>
<pre><code>#include &lt;SPI.h&gt;

byte a[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  SPI.transfer(a, 4);
  SPI.endTransaction();
  delay(10);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/JnNgx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JnNgx.png" alt="enter image description here" /></a></p>
 37523: <p>When you call <code>SPI.transfer(a, 4);</code>, any &quot;received data&quot; is stored in your byte array, <code>a[]</code>. The original data is overwritten.</p>
<p>If you print out the contents of the array before and after the function call to <code>SPI.transfer()</code>, you will see in the serial monitor what is happening to your array contents.</p>
<p>Here are 2 test sketches to illustrate the difference between the array with a global scope, VS the one with a static scope.</p>
<p><strong>Global Scope</strong></p>
<pre class="lang-cpp prettyprint-override"><code>// Sketch uses 2344 bytes (7%) of program storage space.
// Global variables use 193 bytes (9%) of dynamic memory. 
#include &lt;SPI.h&gt;

byte a[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}
</code></pre>
<p><strong>Static Scope</strong></p>
<pre class="lang-cpp prettyprint-override"><code>// Sketch uses 2410 bytes (7%) of program storage space.
// Global variables use 193 bytes (9%) of dynamic memory. 
#include &lt;SPI.h&gt;

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}

</code></pre>
<p>The following sketch should solve the problem. Using the <code>const</code> keword before the declaration of the <code>b[]</code> array is optional.</p>
<pre class="lang-cpp prettyprint-override"><code>// Sketch uses 2436 bytes (7%) of program storage space.
// Global variables use 197 bytes (9%) of dynamic memory. 
#include &lt;SPI.h&gt;
const byte b[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  memcpy(a, b, sizeof(b));
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}

</code></pre>
<p>One last edit. The compile size can be reduced by 66 bytes thanks to the <code>static</code> keyword.</p>
<pre class="lang-cpp prettyprint-override"><code>// Sketch uses 2370 bytes (7%) of program storage space.
// Global variables use 197 bytes (9%) of dynamic memory. 
#include &lt;SPI.h&gt;
const byte b[] = {0xC,0xFF,0xFF,0xFF};

void setup() {
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE3));
  static byte a[] = {0xC,0xFF,0xFF,0xFF};
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println();
  SPI.transfer(a, 4);
  SPI.endTransaction();
  memcpy(a, b, sizeof(b));
  for(int i = 0; i &lt; 4; i++){
    Serial.print(a[i]);
  }
  Serial.println('\n');
  delay(1000);
}
</code></pre>
<p>For more information, see: <a href="https://www.arduino.cc/en/Reference/SPITransfer" rel="noreferrer">Arduino.cc</a></p>
