No spi clock when using the SPI library (Uno)

Hello,

I am using the Arduino Uno and have the following program. But when I measure the SPI clock using the oscilloscope, I do not see any clock signals.

#include <SPI.h>
int i;

void setup (void) {
Serial.begin(115200); //set baud rate to 115200 for usart
digitalWrite(SS, HIGH); // disable Slave Select
SPI.begin ();
}

void loop (void) {
int a = 0;
digitalWrite(SS, LOW); // enable Slave Select
// send test message
for(i=0; i<9; i++)
{
a++;
SPI.transfer (a);
Serial.print (a);
Serial.println();
delay(300);
}

  digitalWrite(SS, HIGH); // disable Slave Select
  delay(500);

}

@parth_bhimani
You posted in the wrong section, please read the description of a section before you post. The section you posted in said NOT for your project.
Moved it here.

I suggest that you read How to get the best out of this forum. Pay special attention to the section how to post code. Next edit your post, select all code and apply the code tags as described.

You will need to setup your scope correctly to see the clock pulses, they are a set of 8 only 250nS apart.

Easier to see if you remove this code;

Serial.print (a);
Serial.println();
delay(300);

Start by slowing down the SPI transfer rate so you have a chance of seeing the clock signal or change your loop so it is continuously transferring data without a pause. This will give you time to adjust the oscilloscope. Which pin are you monitoring?

After removing the delay I can see the clock.
Thanks.

For situations where the signal is infrequent use single-trigger mode on the 'scope. Auto-mode will tend to lose/miss rare events like this.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.