请教各位老师,DSP5505 I2C 与DAC通信,DSP为主设备向DAC发送数据,之前是能工作的,但自从把原来的DAC用热风枪吹下来换了一片DAC,程序运行一直卡在等待发送寄存器准备状态(红色标出),单步运行可以通过,请问有遇到此类问题的老师吗,是DSP的问题还是DAC的问题,难道是DSP虚焊了?请各位老师不吝赐教,小弟感激不尽~~~~
Int16 I2C_DAC_write(int chan_num, Uint16 data)
{
Int16 timeout, i;
Uint8 control_byte,data1,data2;
Uint8 i2cdata[3] = {0,0,0};
Uint16 len = 3; // number of data word to be transmitted
Uint8 i2c_addr = 0x4F; //DAC slave address
//I2C_IER = 0x0000;
I2C_CNT = len; // Set number of bytes(data word) to write
I2C_SAR = i2c_addr; // Set I2C slave address
I2C_MDR |= MDR_STT // start
| MDR_TRX // transmit
| MDR_MST // master
| MDR_IRS // Release from reset
| MDR_FREE; // free run regardless of the breakpoint
wait(5); // Short delay
/**************control byte to be transmitted**********************************************/
switch(chan_num)
{
case 0: control_byte = 0x10;
break;
case 1: control_byte = 0x12;
break;
case 2: control_byte = 0x14;
break;
case 3: control_byte = 0x16;
break;
default:
while(1);
}
/* *********change the 16bit word to 8 bit byte,MSB first to be transmitted **************/
data1 = (data & 0x0FF0);
data1 = data1 >> 4;
data2 = (data & 0x000F);
data2 = data2 << 4;
i2cdata[0] = control_byte; //control byte
i2cdata[1] = (Uint8)data1; //MSB data
i2cdata[2] = (Uint8)data2; //LSB data
/***********发送数据***********************************************/
for ( i = 0 ; i < len ; i++ )
{
I2C_DXR = i2cdata; // Write
while ( ( I2C_STR & STR_XRDY ) == 0 ); //wait for TX ready
}
I2C_MDR |= MDR_STP; // Generate STOP
wait(100);
return 0;
} |