Send Byte using SPI in Arduino Nano

Hi,
I just wanted to confirm whether the following code is correct for sending out a byte of data (only once) using the SPI library in Arduino Nano.

I am asking so because I am very new to using Arduino and am facing some issues when using this for my project.

Thanks in advance.

#include <SPI.h>

uint8_t const ssFPGA = 10;

void setup()
{
  Serial.begin(115200);
  while (!Serial) 
  {
    ; // wait
  }
  SPI.begin();
  pinMode( ssFPGA, OUTPUT );
}

void loop() 
{
    digitalWrite( ssFPGA, 0 );
    delay( 10 );
    SPI.beginTransaction( SPISettings(16000000, MSBFIRST, SPI_MODE3 ) );
    {
         SPI.transfer(0x12);
         //SPI.transfer(0x34); // -----> 2nd byte
         //SPI.transfer(0x56); // -----> 3rd byte
    }
    SPI.endTransaction();
    digitalWrite( ssFPGA, 1 );
    while(1);
}

Nick Gammon's article on SPI was very useful to me: Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino

Pieter

Hi,
Actually, I have already gone through this page.

What if I want to send a specific byte instead of a string, then how should I modify my code (or use the code provided at the forum you just mentioned and modify that) to achieve that ?

Thanks for the reply.

Just change this:

  // send test string
  for (const char * p = "Fab" ; c = *p; p++)
    SPI.transfer (c);

to this:

  uint8_t specificByte = 0x7F;
  SPI.transfer (specificByte);

Pieter