|
关于6410 IIC读写AT24C02!做过的请进!
[复制链接]
这两天在编写测试6410 IIC,发现一个非常奇怪的问题,
读数据时会产生数据终止,不是每次都会,但多读了几次就一定会产生数据异常。异常信息如下:
Exception 'Data Abort' (4): Thread-Id=01840006(pth=85aa48d4), Proc-Id=00400002(pprc=82699308) 'NK.EXE', VM-active=04ec0006(pprc=849cda50) 'explorer.exe'
PC=c0b721cc(s3c6410_iic.dll+0x000021cc) RA=c0b721b8(s3c6410_iic.dll+0x000021b8) SP=d283fe64, BVA=0004f2cd
应用里面读取一Byte数据函数如下:
void CIICDlg::IICReadModeOneByte(void)
{
UCHAR OutputBuf=0;//read on byte
DWORD ReadBytes;
IIC_IO_DESC IIC_AddressData, IIC_Data;
char AddrBuf[4];
UCHAR WordAddr=0;
CString str;
char xx[4];
m_addr_buf.GetWindowTextW(str);
wcstombs(AddrBuf, str, sizeof(AddrBuf));//str->pOutput
WordAddr = atoi(AddrBuf);
RETAILMSG(1, (TEXT("[APP IICReadModeSingle]: WordAddr = 0x%x\r\n"), WordAddr));
/*Dummy write*/
IIC_AddressData.SlaveAddress = IicSet.slave_addr;//write
IIC_AddressData.Data = &WordAddr;//start addr
IIC_AddressData.Count = 1;//sizeof(WordAddr);
IIC_Data.SlaveAddress = IicSet.slave_addr;//|0x1;//read
IIC_Data.Data = &OutputBuf;
IIC_Data.Count = 1;//sizeof(OutputBuf);
if (!DeviceIoControl(hIic,IOCTL_IIC_READ, &IIC_AddressData, sizeof(IIC_IO_DESC), &IIC_Data, sizeof(IIC_IO_DESC),&ReadBytes, NULL))
{
m_receive_buf.SetWindowTextW(TEXT("IIC read single data failed !"));
}
else
{
}
}
|
|