Post Go back to editing

AD5641 SPI communication with Arduino

Hey everyone I have a problem communicating with a AD5641 DAC. I am making this project with Arduino UNO and I can't seem to figure out how to properly send data to the DAC. If someone can give me an example or explain how to send data to this DAC I'd appreciate it.

Parents
  • Here are some screenshots:

    Yellow is the slave select line, Green is the Data line and Blue is the clock.

    This is the SPI communication part of the code:

    void digitalDACWrite(int value) {        // SPI transfer function

    if (State == 0) outputValue = ButtonDAC; // Inputs an address for the DAC from the buttons when pushed

    else outputValue = value;                // Inputs an address for the DAC from the encoder when rotated

    digitalWrite(slaveSelectPin, LOW);                   // Puts the Slave select to LOW to prepare for transfer cycle

    data = highByte(outputValue);            // Starts a conversion of the selected value to binary first the high byte

    data = 0b00001111 & data;                // Bitwise AND

    data = 0b00110000 | data;                // Bitwise OR

    SPI.transfer(data);                      // Transfers the high byte via SPI

    data = lowByte(outputValue);             // Converts the rest of the selected value to binary the low byte

    SPI.transfer(data);                      // Transfers the low byte via SPI

    digitalWrite(slaveSelectPin, HIGH);                  // Puts the Slave select to HIGH to stop for transfer cycle

    }

Reply
  • Here are some screenshots:

    Yellow is the slave select line, Green is the Data line and Blue is the clock.

    This is the SPI communication part of the code:

    void digitalDACWrite(int value) {        // SPI transfer function

    if (State == 0) outputValue = ButtonDAC; // Inputs an address for the DAC from the buttons when pushed

    else outputValue = value;                // Inputs an address for the DAC from the encoder when rotated

    digitalWrite(slaveSelectPin, LOW);                   // Puts the Slave select to LOW to prepare for transfer cycle

    data = highByte(outputValue);            // Starts a conversion of the selected value to binary first the high byte

    data = 0b00001111 & data;                // Bitwise AND

    data = 0b00110000 | data;                // Bitwise OR

    SPI.transfer(data);                      // Transfers the high byte via SPI

    data = lowByte(outputValue);             // Converts the rest of the selected value to binary the low byte

    SPI.transfer(data);                      // Transfers the low byte via SPI

    digitalWrite(slaveSelectPin, HIGH);                  // Puts the Slave select to HIGH to stop for transfer cycle

    }

Children
No Data