2

I was attempting to use an SPI library and DAC device (Library AD57X4) for the first time, when I realized that the Arduino UNO Pin 13 was not outputting a clock signal (something I expected it to do).

Using a serial analyzer I can sample at 16MHz, yet nothing comes out of UNO Pin 13 except maybe a very occasional noise blip. After no luck with the AD57X4 library, I wrote this simple program to try to get SPI clock signal on UNO Pin 13. Setting UNO Pin 13 to OUTPUT makes no difference.

#include <SPI.h>

void setup() {
  //pinMode(13, OUTPUT);
  SPI.begin();

}

void loop() {
  SPI.transfer(0x00);  
}

enter image description here

I do get a signal on UNO Pin 11 (MOSI), frequency 381 kHz. This signal is due to SPI.transfer(0x00); , as it disappears when the line is removed. Although likely irrelevant to the question, I noticed some periodic 6us gaps every ~1ms on this UNO Pin 11 (MOSI) signal.

enter image description here

enter image description here

The Blink Example Works:

    // the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

enter image description here

I tried monitoring UNO ICSP header pin 3 (SCK), however there is no signal for either the SPI or Blink programs.

enter image description here

UPDATE: I switched over to an Arduino NANO that I had around and was able to get this output. I expected the clock to be high frequency and continuous for SPI. The MOSI output is the same 381 kHz that I observed earlier.

enter image description here

enter image description here

#include <SPI.h>

void setup() {
  pinMode(13, OUTPUT);
  SPI.begin();

}

void loop() {
  SPI.transfer(0x00);  
}

EDIT: Here is a schematic of my circuit. I am using an EVAL-AD5754R Evaluation Board from Analog Devices. Here is a link to the AD5754 chip data sheet. I'm providing 5V power through the J7 terminal (via the UNO), and supplying the SPI connections through the J8 header. The EVAL-AD5754R board works perfectly via USB and their software, but now I am transitioning to controlling it through Arduino/SPI. As you can see I'm temporarily using a 12V battery for the analog voltage supply - this is until I build a regulated circuit. J8 DGND pins are shown unconnected on the schematic below, but I've tried connecting one of them to the UNO's GND to no effect.

enter image description here

This is the configuration of the linkers which act to configure the eval board: enter image description here

This is an annotated table describing J8 header connections (UNO <-> EVAL-AD5754R): enter image description here

  • Can you post your schematic? And the exact part number (and preferably a link to the datasheet) of your DAC device. – Nick Gammon Mar 22 '18 at 5:30
  • @NickGammon I am using EVAL-AD5754R from Analog Devices. I edited the question to include a schematic of the UNO and the configuration of the DAC board. – user391339 Mar 22 '18 at 9:01
  • 1
    set pin 10 as output in test sketch, to prevent uno to fall into slave role with the SPI library – Juraj Mar 22 '18 at 9:18
2

I can't reproduce that. Using your first test code:

#include <SPI.h>

void setup() {
  //pinMode(13, OUTPUT);
  SPI.begin();

}

void loop() {
  SPI.transfer(0x00);  
}

I get this on the logic analyzer:

Logic analyzer - SPI

Also on my scope on pin 13:

Scope capture - SPI

As expected, a 4 MHz signal with gaps between the bytes.


I expected the clock to be high frequency and continuous for SPI.

No, you get the clock when data is being transmitted and not at other times.

Although likely irrelevant to the question, I noticed some periodic 6us gaps every ~1ms on this UNO Pin 10 (MOSI) signal.

That would be the Timer 0 interrupt kicking in (roughly every 1 ms) and thus interrupting your looping code for a few microseconds.


Possible solution

Try enabling slave select (write LOW to pin 10). I think some versions of the logic analyzer ignore incoming data if the slave isn't selected.

In fact, pin 10 should be an output, otherwise the SPI hardware goes into slave mode. Some versions of the library might not set it to output.

  • I'm going to try this tomorrow. I was able to draw a schematic of my circuit above. – user391339 Mar 22 '18 at 8:59
  • I was able to get the clock signals now as expected. Library still not working for me (a separate question), but at least I can now see the signals on the SPI! Thanks – user391339 Mar 22 '18 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.