Hi,
I am trying to control a VCO with the DAC for some RF circuit.
The MSP430 that I use, has an output streambit of 8bit (or 7), and the DAC needs a 16 bit input. I have read that I need to send 2 bytes. I have tried a 1000 ways to do that but it will not work.
Right now, my aim is just to send only one 16 bit stream like for example 1000 0000 0000 0000 to the DAC and get a voltage output of Vref/2. That's it, from that point on I can grow :).
The last code that I tried is:
#include "msp430x22x4.h"
void main(void) {
double data1,data2,i;
int byte0, byte1;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P3SEL |= 0x0A; //We activate P3.1 and P3.3 (pin10 and 12) for USCI mode
P4DIR |= 0x2A; //we activate as outputs P4.1, P4.3 and P4.5 (pins: 16, 18 and 20). This are the CS controlls to controll 3VCO's, that is my final objective.
P4OUT &= 0x00; //Make sure that everything is low
P4OUT |= 0x28; //we set high P4.3 and P4.5, so data only goes to P4.1. Remeber that data loads on low
UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master, Sinchronous mode
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 |= 0x02;
UCB0BR1 = 0;
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
byte0 = 0x10000000;
byte1 = 0x00000000;
while ((IFG2 & UCB0TXIFG) == 0); //wait until buffer is ready
UCB0TXBUF = byte0; // Send clocks to the DAC, this shifts 1st byte
while ((IFG2 & UCB0TXIFG) == 0);
UCB0TXBUF = byte1 ; // Send clocks to the DAC, this shifts 2nd byte
P4OUT |= 0x02; Turn the CS of the DAC on high
}
I have also a 18bit DAC9881, would I have to send 3 bytes?
Thank you very much for your help. I have tried for several days, and I have been doing some research on the web but I couldn't find anything helpfull.