This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC104S085设置与输出

Other Parts Discussed in Thread: DAC104S085

DAC104S085的DIN,SCLK, SYNC分别与MSP430单片机P9.3、P9.1、P9.0连接,DAC参考电压3V,单片机时钟频率18.432MHz,SPI时钟频率18.432\9=2.048MHz,SPI初始化如下:

void Init_SPI2(void)

 {     

 P9SEL |=BIT1+BIT3;  

P9SEL &=~BIT0;    

P9DIR|=BIT0+BIT1+BIT3; // 

P9OUT&=~BIT0;    

UCB2CTL1 |= UCSWRST                                     ; // 复位SPI状态机  

UCB2CTL0 |= UCMST+UCSYNC+UCMSB                   ; // 3-pin, 8-bit SPI master,  MSB   // 

UCB2CTL1 |= UCSSEL__SMCLK                                    ; // 选择SCK参考源为SMCLK  

UCB2BR0   = 0x09                                        ; // SCK = SMCK/9 

UCB2BR1   = 0                                           ;  

UCB2CTL1 &=~UCSWRST                                     ; // SPI状态机使能

 }

SPI2发送数据程序如下:

void TransceiveSPI2 (char txdata)      //发送

 {   

while (!(UCB2IFG & UCTXIFG));             // wait until last SPI-Transmission is finished      

UCB2TXBUF = txdata;                         // send 8 clocks "txdata" and SPI-clocks

}

设置DAC OUT A程序如下:

void SetDAC_A(unsigned int DigData)

 {   

unsigned int Data=0;     

 Data=0x1000+DigData;   //高四位0001     (00 0 1 设置A,更新输出)

P9OUT &=~BIT0;    

 __delay_cycles(18432);      

TransceiveSPI2((Data&0xFF00)>>8);   //MSB

 // __delay_cycles(18432);    

TransceiveSPI2(Data&0x00FF);    

 __delay_cycles(18432);    

 P9OUT|=BIT0;           

}

main函数如下:

void main( )

{       

Init_CLK();       //系统时钟初始化

 Init_SPI2();                //          

while(1)    

 {      

SetDAC_A(0x200); //0x200---1.5V      

 __delay_cycles(184320000);     //10s延时

}

}

通过检测发现,A输出一直不对,不知道问题出在哪儿?对DAC104进行操作,16位数据分两次写,两次操作间需要延时吗?