1
\$\begingroup\$

I am trying to use an LPC11C24 microcontroller to send digital values to a DAC8718 to convert to an analog voltage value. I am attempting to communicate via SPI and I am using mbed.h with the SPI.h capability to send an arbitrary stream of bits to the DAC. However I am not seeing any output on the DAC output. I am communicating via a PCAN-USB dongle. Here is my code:

#include "mbed.h"

CAN can(NC, NC);
DigitalOut chipsel(P2_0);


int main() {
  // Init CAN
  can.frequency(125000);
  // Main loop
  SPI device(P2_3, P2_2, P2_1);
  device.frequency(1000000);
  device.format(16,2); // 16 bits
  chipsel = 0;
  chipsel = 1;
  float response;

  while(1) {
    response = device.write(0xFFFF);
  }
}

What am I doing wrong and what should I do to record output on the DAC?

\$\endgroup\$
  • \$\begingroup\$ I'm assuming the SPI.h is included in the mbed.h header? \$\endgroup\$ – Funkyguy Jul 11 '14 at 21:12
1
\$\begingroup\$

Since it looks like you want to do a Read back write operation, try this:

#include "mbed.h"

CAN can(NC, NC);
DigitalOut chipsel(P2_0);


int main() {
// Init CAN
can.frequency(125000);
// Main loop
SPI device(P2_3, P2_2, P2_1);
device.frequency(1000000);
device.format(8,3); // 16 bits
chipsel = 0;
chipsel = 1; - remove this
float response;

while(1) {
    chipsel = 0;
    device.write(0x88FFFF); // dont need to care about response, writes max voltage to DAC0, look on page 47 and 48 of TI docs
    chipsel = 1;
    // wait some time here, not sure about wait timing here
    chipsel = 0;
    response = device.write (0xFFFFFF); // write NOP command and read data returned
    chipsel = 1;
    // do whatever with response
}

}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.