Other Parts Discussed in Thread: MSP430F2616, TLV5626
Hello,
I have interfaced TLV5626 to MSP430F2616. It is a 3 wire interface with MSP as the master. The port pins used are P3.0, 1,&3 (UCBSTE, UCB0SIMO,UCB0CLK). As per the application information of the device I am first writing the setting(s) of the device to the control register and is followed by writing the DAC value. I am not getting any output. Could anyone go through the code listed below and indicate to me if I am making an error.
I am using an HFXTL - 8 MHz.
BCSCTL1 &= ~XT2OFF; // Activate XT2 high freq xtal
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_2+SELS; // MCLK = XT2 HF XTAL (safe).
// ----------- SPI Port Setup.
P3DIR |= BIT0+BIT1+BIT3; // o/p dir for P3.0(ste)
P3OUT |= BIT0; // CS signal - o/p HIGH.
P3SEL |= BIT1+BIT3; // P3.3,1 option select
UCB0CTL1 = UCSSEL_2+ UCSWRST; // **Put state machine in reset**
UCB0CTL0 |= UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
UCB0BR0 = 0x02; // SMCLK/2
UCB0BR1 = 0;
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
for(i=0xff;i>0;i--); // delay.
_NOP();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// --- Send Control word 0xD002, [ ref = 2.048, fast mode ] MSB First..,
P3OUT &= ~BIT0; // CS = Low (device selected).
for(i=0xff;i>0;i--); // delay
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xD0; // msb first
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x02;
for(i=0xff;i>0;i--); // delay.
P3OUT |= BIT0; // CS = High (deselected).
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for(i=0xffff;i>0;i--); // delay
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// data = 0x500, i.e, o/p = 1.2 volts.
P3OUT &= ~BIT0; // CS = Low (device selected).
for(i=0xff;i>0;i--);
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xC5;
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x00;
for(i=0xff;i>0;i--);
P3OUT |= BIT0; // CS = High (deselected).
//----------------------------------------------------------------------
Regards
Prasad