Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I am trying to use a AD5061 [1] with an Arduino Due (Arm 3.3v). Same DAC works as intended when using a Uno (atmega 328 5v). I am trying to create analog signal to control a motor driver. Using the following code,

#include <SPI.h>

int motorPin = 6;

void sendMotorSPI(int motorPin, int msb, int lsb) {
  digitalWrite(motorPin, LOW); // select slave (low active)
  delayMicroseconds(1);
  SPI.transfer(00000000);
  SPI.transfer(msb);
  SPI.transfer(lsb);
  delayMicroseconds(1);
  digitalWrite(motorPin, HIGH); //deselect slave (high passive)
}

void setup() {
  SPI.setBitOrder(MSBFIRST);   //most sign. bit
  SPI.setDataMode(SPI_MODE1); // spi mode (must be 1)

  pinMode(motorPin, OUTPUT);
  digitalWrite(motorPin, HIGH);
}

void loop(){
  SPI.begin();

  unsigned int value = 100;
  value = value << 8;
  byte MSB = (value & 0xFF00) >> 8;
  byte LSB = 0x00FF & value;

  sendMotorSPI(motorPin, MSB, LSB);

  while(1);
}

It is connected like the following to the Uno and works as intented,

Pin 6 -> SYNC
Mosi -> Din
SCK -> SCLK

However I can not get it to work on the Due, I suspected 3.3v might be the problem so I used a transistor to push all lines to 5v, but still I can not get it work.

[1] http://www.analog.com/en/products/digital-to-analog-converters/da-converters/ad5061.html

share|improve this question

migrated from electronics.stackexchange.com Mar 19 at 17:43

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.