DAC80501 Help

d10

Member
Hello.
I have been trying to get this DAC80502-01 evaluation Board to output a signal other than zero.

In the the 8051 datasheet, it states that the CS pin needs to stay low for at least 24 clock cycles, otherwise it goes into sync interrupt mode which sets the DAC output to zero.

"For SPI-mode operation, the SYNC line stays low for at least 24 falling edges of SCLK and the addressed
DAC register updates on the SYNC rising edge. However, if the SYNC line is brought high before the 24th
SCLK falling edge, this event acts as an interrupt to the write sequence. The shift register resets and the write
sequence is discarded. Neither an update of the data buffer or DAC register contents, nor a change in the
operating mode occurs."

Looking at my oscilloscope pictures. After the CS pin goes low, I only get 16 clock cycles before the CS pin goes high again.
You can see in the picture that it writes the command bit to the DAC. but it only writes the MOSI data for 8 clock cycles Instead of the desired 16.

How can I fix this please?

Any help will be most appreciated. Thank you.

Yellow trace is DAC out.
Pink trace is SCLK.
Blue trace is CS.
Green Trace is MOSI.

Code:
// set pin 10 as the slave select:
const int slaveSelectPin = 10;

uint8_t  device_ID_command = 0x01;
uint16_t device_ID = 0x0115;
uint8_t  trigger_command = 0x05;
uint16_t soft_reset = 0x000A;
uint8_t  dac_out_command = 0x08;

uint16_t dac_data = 0xFFFF;



void setup() {
  Serial.begin(9600);
  pinMode (slaveSelectPin, OUTPUT);
  digitalWrite (slaveSelectPin, HIGH);
  SPI.begin();
  spi_Write(trigger_command, soft_reset); // software reset
  delay(10);
  spi_Write(device_ID_command, device_ID); // Device ID
  delay(10);
}

void loop() {
      dac_data = 0xFFFF;
      spi_Write(dac_out_command, dac_data);   
      Serial.print(" dac_data ");
      Serial.println(dac_data, HEX);

      dac_data = 0x0000;
      spi_Write(dac_out_command, dac_data); 

      Serial.print(" dac_data ");
      Serial.println(dac_data, HEX);
}

void spi_Write(uint8_t command_byte, uint16_t data_byte) {

  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));//4000000
  // take the SS pin low to select the chip:
  digitalWrite(slaveSelectPin,LOW);
  //  send in the address and value via SPI:
  SPI.transfer(command_byte);
  SPI.transfer(data_byte);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin,HIGH);
  SPI.endTransaction();
 
  //Serial.print(" command_byte ");
  //Serial.print(command_byte, HEX);
  //Serial.print(" data_byte ");
  //Serial.print(data_byte, HEX);
}
 

Attachments

  • SDS00001.png
    SDS00001.png
    39.5 KB · Views: 22
  • SDS00003.png
    SDS00003.png
    29.4 KB · Views: 23
  • SDS00005.png
    SDS00005.png
    29.7 KB · Views: 23
There may be other issues, but your spi_Write function is calling SPI.transfer(data_byte), which sends one byte, but data_byte is type uint16_t, which is two bytes. You at least need to send both bytes of the data value. You might want to rename "data_byte" to "data_word".

Code:
  SPI.transfer(command_byte);
  SPI.transfer(data_byte >> 8);      // send m-s byte
  SPI.transfer(data_byte & 0x0ff);    // send l-s byte
 
  • Like
Reactions: d10
Hi,

I was just typing what @joepasquariello said..

A couple of other points you might want to look at:
- have you got the right SPI_MODE? The data sheet says it clocks the data on falling edge (SPI_MODE 1 or SPI_MODE2?)
- in loop you're sending full output then zero output straight after it, you might want to stick a delay in between them while testing

cheers, Paul
 
  • Like
Reactions: d10
Back
Top