Vlad.
Full Member level 3
- Joined
- Jun 4, 2012
- Messages
- 179
- Helped
- 3
- Reputation
- 6
- Reaction score
- 4
- Trophy points
- 1,298
- Location
- Bucharest/Romania
- Activity points
- 2,568
Hello guys, I am trying to interface arduino uno with SPI DAC from Maxim Integrated (MAX531). The cofiguration i use on this DAC is unipolar configuration. Based on how I understand the datasheet I write a code but doesn't work. If can someone help it will be great.
this is my code
this is my code
Code:
// inslude the SPI library:
#include <SPI.h>
const int slaveSelectPin = 10; // set pin 10 as the slave select
const int clrPin=9; //set pin 9 for clear DAC >> optional
int max_value=4095; // max value for DAC
int min_value=0; //min value dor DAC
int value;
int AByte = 0;
int command = 0b000000000000; // 0100 Load input and DAC registers from shift register; DAC output updated.
int data = 0b111111111111; // desired DAC output.
int commandPlusData = command | data;
void setup() {
Serial.begin(9600);
// set the slaveSelectPin as an output:
pinMode (slaveSelectPin, OUTPUT);
digitalWrite (slaveSelectPin, HIGH);
pinMode (clrPin,OUTPUT);
digitalWrite (clrPin, HIGH); // clear DAC
// initialize SPI:
SPI.begin();
}
void loop() {
SPI.transfer (highByte (commandPlusData));
SPI.transfer (lowByte (commandPlusData));
digitalWrite (slaveSelectPin, HIGH);
delay(80);
}