|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
请问s3c2410的iic 端口在写eeprom时寄存器如何配置?我这样写为什么读不到数呢?显示读数均为0xff!哪位大侠告诉我一下呀
我用的eeprom是at4aa256
void iic_write(U32 slvAddr,U32 addr,U8 data)
{
rIICADD = slvAddr;
rIICDS = slvAddr;
rIICCON = 0xaf;
rIICSTAT = 0xf0;
Delay(1);
rIICDS = addr;
rIICCON = 0xaf;
Delay(1);
rIICDS = data;
rIICCON = 0xaf;
Delay(1);
rIICSTAT = 0xd0;
rIICCON = 0xaf;
Delay(5);
}
void iic_read(U32 slvAddr,U32 addr,U8 *data)
{
char cRecvByte;
rIICADD = slvAddr;
rIICDS = slvAddr;
rIICSTAT = 0xf0;
Delay(1);
rIICDS = addr;
rIICCON = 0xaf;
Delay(1);
rIICDS = slvAddr;
rIICSTAT = 0xb0;
rIICCON = 0xaf;
Delay(1);
//get data
cRecvByte = rIICDS;
rIICCON = 0x2f;
Delay(1);
//get data
cRecvByte = rIICDS;
//end receive
rIICSTAT = 0x90;
rIICCON = 0xaf;
Delay(5);
* data = cRecvByte;
}
void iic_test()
{
U8 data[10];
int i;
i=0x0;
Uart_Printf("iic_test\n");
// rINTMOD = 0x0;
// rINTMSK &= ~(0x1<<27);
// pISR_IIC = (unsigned)iic_int;
for(i=0;i<10;i++)
{
Uart_Printf("iic_write %x\n",i);
iic_write(0xa0,i,i);
Delay(5000);
}
for(i=0;i<10;i++)
{
data=0x55;
}
i = 0;
for(i=0;i<10;i++)
{
iic_read(0xa0,i,&(data));
Uart_Printf("iic_read %x = %x\n",i,data);
Delay(5000);
}
}
|
|