我在用 MSP430F6638和DAC8571进行I2C总线配置是发现时钟有时出不来 有时时钟能出来的话 但是收不到 DAC8571 的应答信号 其中DAC8571的 A0接地 所以从机地址为0x4C 请问 UCB1能否配置出I2C总线或者 是不是UCB1 不稳定 求解决方案
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.
我在用 MSP430F6638和DAC8571进行I2C总线配置是发现时钟有时出不来 有时时钟能出来的话 但是收不到 DAC8571 的应答信号 其中DAC8571的 A0接地 所以从机地址为0x4C 请问 UCB1能否配置出I2C总线或者 是不是UCB1 不稳定 求解决方案
#include "msp430f6638.h"
#include "user\system.h" //这个是配置适中的头文件
#include "user\I2C.h"
void InitI2C(void)
{
P8SEL|=BIT6+BIT5;
//P8DIR|=BIT5+BIT6;
UCB1CTL1|=UCSWRST;
UCB1CTL0|=UCMST+UCSYNC+UCMODE_3 ; //选择I2C模式
//UCB0CTL&=~I2CEN; //禁止I2C模块
UCB1CTL1=UCSSEL_2+UCTR; //设置I2C为7位地址模式,不使用DMA,字节模式,时钟源为SMCLK,设置成传输模式
//UCB1I2CSA=0X98; //定义从器件地址 默认为dac8571地址 其A0=0;写操作
UCB1I2COA=0X045; //设置本身的地址
UCB1BR0=40; //I2C时钟为SMCLK / 160
UCB1CTL1&=~UCSWRST;
}
void main( void )
{ unsigned int i;
unsigned char Com,H,L;
//unsigned char H,L;
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
//initial
SysCtrlInit();
//BUS_Init();
//Lcd_Init();
//lcd_clear();
//SPIA1_Init();
InitI2C();
i=0;
while(1)
{
Com=0x10 ;
H= 0x40 ;
L=0x00 ;
UCB1I2CSA=0x4C;
UCB1CTL1|=UCTR;
cal:
UCB1CTL1|=UCTXSTT;
UCB1TXBUF=Com;
while (UCB1CTL1&UCTXSTT)
{
if(UCB1IFG&UCNACKIFG) goto cal;
}
while (!(UCB1IFG&UCTXIFG)) ;
UCB1TXBUF=H;
while (!(UCB1IFG&UCTXIFG)) ;
UCB1TXBUF=L;
while (!(UCB1IFG&UCTXIFG)) ;
UCB1CTL1|=UCTXSTP;
//__delay_cycles(100);
while (UCB1CTL1 & UCTXSTP);
}
这个是源代码 但是没有时钟输出
}