我使用NUC126的範例程式
執行I2C.C所提供的library
對一個byte位址進行寫入及讀取
在讀取時會產生錯誤
是哪裡沒處理好呢?
g_u8DeviceAddr = 0x50;
u16DataAddr = 0x0010
ret_code = I2C_WriteByteTwoRegs(I2C0, g_u8DeviceAddr, u16DataAddr, 32) ;
if( ret_code == 0 )
printf("One byte write Pass.....\n");
else
printf("One byte write Failed..%d...\n",ret_code);
g_u8DeviceAddr = 0x50;
u16DataAddr = 0x0010 ;
ret_code = I2C_ReadByteTwoRegs(I2C0, g_u8DeviceAddr, u16DataAddr) ;
if( ret_code == 32 )
printf("One byte read Pass.....\n");
else
printf("One byte read Failed....%d\n",ret_code);
-----------------------------------------------------------
執行結果
One byte write Pass.....
One byte read Failed....0 |