DAC communication via SPI


hi, have project utilizes use of dac. first used 1 mcp4921 , had success following code
code: [select]
void digitaldacwrite(int value) {        //
if (state == 0) outputvalue = buttondac; // inputs address dac buttons when pushed
else outputvalue = value;                // inputs address dac encoder when rotated
digitalwrite(10, low);                   // puts slave select low prepare transfer cycle
data = highbyte(outputvalue);            // starts conversion of selected value binary first high byte
data = 0b00001111 & data;                // bitwise and
data = 0b00110000 | data;                // bitwise or
spi.transfer(data);                      // transfers high byte via spi
data = lowbyte(outputvalue);             // converts rest of selected value binary low byte
spi.transfer(data);                      // transfers low byte via spi
digitalwrite(10, high);                  // puts slave select high stop transfer cycle
}

p.s. wrote comments correct me if wrong.

but sadly needed more resolution , got 1 ad5641. thought spi communication protocol enough work 1 did previous wrong.

p.s.s. might connection problem, highly unlikely, , yes i've checked faulty wiring , found nothing(yet).

if tell me or guide me how fix problem i'd happy.

p.s.s.s. i've attached full code since big post, , clarify previous dac used 4095 following:
code: [select]
int dacbits = 16384;     // variable storing dac's bits steps since new dac 14-bit changed it.








Arduino Forum > Using Arduino > Programming Questions > DAC communication via SPI


arduino

Comments