void IICRead(unsigned int i ) // read data by my understanding
{
IICInit();
rIICDS = 0xA1;
rIICSTAT = 0xB0;
while( rIICSTAT & 0x1 ); //wait ACK
ClearInt();
buf[i] = rIICDS;
Uart_Printf("buf[");
Uart_Printf("%d",i);
Uart_Printf("]: %X\n",buf[i]);
rIICCON = 0xE0; //resume iic,generate ACK
while( rIICSTAT & 0x1 ); //wait ACK
buf[i] = rIICDS;//单步调试这里就出数据了
Uart_Printf("buf[");
Uart_Printf("%d",i);
Uart_Printf("]: %X\n",buf[i]);
ClearInt();
rIICSTAT = 0x90;
rIICCON = 0x60; //resume iic, no ACK
while( ! (rIICSTAT & 0x1 ) ); //wait NO-ACK
buf[i] = rIICDS;////全速调试这里才出数据了
Uart_Printf("buf[");
Uart_Printf("%d",i);
Uart_Printf("]: %X\n",buf[i]);
//while( (rIICSTAT >> 5) & 1); //wait stop
IICRest();
}
IIC读个EPPROM(at24c02)
是不是全速跑的时候,时序就乱了?或者说,单步调试的时候,硬件准备的时间足够??? |