This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi @ all!
I'm having ridiculous problems getting a DAC8568 (D Grade) to work at all. It DID work somehow, then I seem to have fumbled the commands, now it's completely all over the place.
My configuration:
Teensy 4.1 MCU. Clock, Data and Chip Select lines are connected correctly, LDAC is grounded, CLR is at VDD (5 volts). I don't want to use LDAC and CLR functions, I want to write and update voltages immediately.
Channel_A output goes into an OPA2134 half, configured as a voltage follower. V+ is also at 5 volts (for now, later it's gonna be +/- 12 volts), V- is at GND.
I'm measuring with a decent DMM at the output of the op-amp.
This is my test code:
#include <Arduino.h>
#include <SPI.h>
// ----------------------------- DAC and shift register vars
#define DAC_SYNC_PIN 8 // CS pin for pitch DAC8568 (SYNC pin)
#define DAC_MOSI_PIN 11 // MOSI pin
#define DAC_SCLK_PIN 13 // SCLK pin
// ------------------------ Templates
uint8_t null = 0b0000; // Don't care
uint8_t channel_A = 0b0000; // A
uint8_t channel_B = 0b0001; // B
uint8_t channel_C = 0b0010; // C
uint8_t channel_D = 0b0011; // D
uint8_t channel_E = 0b0100; // E
uint8_t channel_F = 0b0101; // F
uint8_t channel_G = 0b0110; // G
uint8_t channel_H = 0b0111; // H
uint8_t channel_ALL = 0b1111; // All
SPISettings spiSettings(1000000, MSBFIRST, SPI_MODE1); // SPI settings
// ------------------------ Write DAC8568
void writeDAC(int SYNC_PIN, uint8_t prefix, uint8_t control, uint8_t address, uint16_t data, uint8_t feature) {
SPI.beginTransaction(spiSettings); // Begin SPI transaction
digitalWrite(SYNC_PIN, LOW); // Sync low
SPI.transfer32((prefix << 28) | (control << 24) | (address << 20) | (data << 4) | feature); // build 32 bit word and send it
delayMicroseconds(10); // Delay
digitalWrite(SYNC_PIN, HIGH); // Sync high
SPI.endTransaction(); // End SPI transaction
}
// ------------------------ Setup
void setup() {
delay(1000); // Wait for 1 second
Serial.begin(115200); // Start serial monitor at 115200 baud
pinMode(DAC_SYNC_PIN, OUTPUT); // Set pitch DAC CS pin as output
digitalWrite(DAC_SYNC_PIN, HIGH); // Sync high
pinMode(DAC_MOSI_PIN, OUTPUT); // Set DAC MOSI pin as output
pinMode(DAC_SCLK_PIN, OUTPUT); // Set DAC SCLK pin as output
SPI.begin();
delay(1000); // Wait for 1 second
writeDAC(DAC_SYNC_PIN, null, 0b1001, null, 0b1010000000000000, null); // Power up internal reference, all time
}
// ------------------------ Loop
void loop() {
for(uint32_t i = 0; i < 65535; i += 2048) {
writeDAC(DAC_SYNC_PIN, null, 0b0011, channel_A, i, null); // Write voltage to DAC channel A register and update register
Serial.println(i);
delay(5000);
}
}
Nothing special, just trying to step through some voltages.
The result: channel_A output slowly oscillates at around 500-ish mV, no change at all.
It worked before, voltage only rose to around 2.5 volts when the voltage counter was at 32768, after that it began at 0 volts again.
I tried a different code, to the same effect. Then i switched to the posted code, doesn't work.
Reading the data sheet over and over again I tried a lot of configs, but I admit, I'm lost now.
Do I have to RESET the whole chip? Is it possible to get it to work after a software reset?
Sorry for the hassle - I re-wired everything as short and tight as possible and put 10k in series at the op-amp buffer output. Now everything works almost as intended.