0

I am using the following code and when I am probing pin 13(SCK), I can't see any clock signal in the oscilloscope.

#include <SPI.h>
int SCS=10;
int SI=11;
int SCLK=13;
int EXTCOMIN=4;
void setup()
{
 pinMode(SCS,OUTPUT);
 pinMode(EXTCOMIN,OUTPUT);
 pinMode(SCLK,OUTPUT);
 digitalWrite(SCS,HIGH);
 tone(EXTCOMIN,50);
 SPI.setClockDivider(SPI_CLOCK_DIV16);
 SPI.begin();
}
void loop()
 {
 }
asked Mar 23, 2015 at 7:07
2
  • 3
    The SPI port is only clocked when you call SPI.transfer(). Commented Mar 23, 2015 at 11:04
  • @EdgarBonet thanks, yeah now I am able to see the clock with the desired frequency Commented Mar 23, 2015 at 12:12

1 Answer 1

2

(META: This question has been answered in the comment section of the question itself. (And I'm also unable to comment to say that he should answer his own question...) That's why I'm putting this answer here.)

You might want to look into the basics of SPI, the clock will only oscillate when there is an actual data transaction in progress. (This will prevent desynchronisation by a bit. And will make both sides know when data is being send. Often along with a SS) You can check this by continiously sending something in your code and then probe the clock pin with an ossciloscope.

You might want to accept this as an answer, so that nobody it's clear this question is already answered.

answered Mar 23, 2015 at 21:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.