Hello,
I'm trying to interface DAC8531 with Arduino Mega trough three-wire serial interface (SPI).I've done all the connections and the skech in ARDUINO IDE to write a value between 0 and 65535 (the input shift register of the DAC is 24 bits wide, the first six bits are “don’t cares”, the next two bits (PD1 and PD0) are control bits, the next 16 bits are the data bits-these are transferred to the DAC register on the 24th falling edge of SCLK.)
The program is:
#include <SPI.h> int CS = 53; //pin53 slave select int Data = 51; //pin51 MOSI serial data int SCLK = 52; //pin52 clock void setup() { // put your setup code here, to run once: pinMode(CS,OUTPUT); pinMode(Data,OUTPUT); pinMode(SCLK,OUTPUT); SPI.begin(); digitalWrite(CS,HIGH); SPI.beginTransaction (SPISettings (2000000, MSBFIRST, SPI_MODE1)); delayMicroseconds(1); } void loop() { // put your main code here, to run repeatedly: DAC_Write(2622); // set dac to ~200mV delay(3000); } void DAC_Write(uint16_t outputValue){ byte command=B00000000; digitalWrite(CS,LOW); SPI.transfer(command); SPI.transfer(highByte(outputValue)); SPI.transfer(lowByte(outputValue)); delayMicroseconds(1); digitalWrite(CS,HIGH); delayMicroseconds(1); SPI.endTransaction (); }
The program it's not working, Arduino's µc it's not writing in the DAC buffer, i don't know if SPI settings are correct or if everything else is in order.
Here is the link for the datasheet of the DAC : http://www.ti.com/lit/ds/sbas192b/sbas192b.pdf
If someone has worked with this DAC, i would appreciate a few opinions and a little help if possible. Thanks a lot.