embeddedmicrocontrolleranalog-digital-convertermbed

VCO with Software Issues


I have a VCO with an AD5791 and LPC1768. I am able to read and write to the DAC register of the AD5791 but unable to modify the output frequency or voltage. When the AD5791 is directly connected to a power supply, I can modify the frequency as expected. Therefore I believe this is a software issue. My code is here:

#include "mbed.h"

SPI spi(p5, p6, p7); // mosi, miso, sclk
DigitalOut cs(p8);
DigitalOut LDAC(p9);
DigitalOut Reset(p11);
DigitalOut CLR(p10);

int main()
{
   spi.format(8,0);
   spi.frequency(10000); // you can speedup later
   cs = 1;

   Reset = 0;
   wait_us(1);
   LDAC = 0;
   CLR = 1;
   Reset = 1; // the chip is reset now

   cs = 0;
   spi.write(20);
   spi.write(0);
   spi.write(0);
   cs= 1; // this will activate dac

   cs = 0;
   spi.write(0x14);
   spi.write(0xCC);
   spi.write(0xCD);
   cs = 1; // set output register - shall output some value

   do{
   }while(1); // wait forever to test the output value

}

Any inputs would be greatly appreciated! Thank you!


Solution

  • The main issue here was that the LPC1768 had to have its software control register and control register set before writing to it. Additionally, the chip had to be driven by LDAC with pauses after data was transferred. This can be seen in my code here: https://gist.github.com/tashwoods/84c81f87fa6e0f1b98a2