新會員
Joined
: 2019/7/23 10:25 最後登入時間
: 2019/12/17 15:52
Group:
註冊會員
Level : 2 HP : 0 / 37 MP : 4 / 527 EXP : 50
|
[size=x-small]各位先進好 我使用MCC的I2C 去寫 程式碼如下 LA看到想寫的data 並沒有輸出 我有遺漏的部分嗎?
uint16_t Start_Address = 0x0B; uint8_t MNFnameCom[5] = { 0xFF ,0x03 ,0xA9 , 0x00 , 0x10 }; uint8_t MNFname[16] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00};
int main(void){ // initialize the device SYSTEM_Initialize(); while (1) { // SMBus Write #define SLAVE_I2C_GENERIC_RETRY_MAX 100 #define SLAVE_I2C_GENERIC_DEVICE_TIMEOUT 50 // initialize the module I2C1_Initialize(); uint16_t timeOut; timeOut = 0; //I2C1_MasterWrite(MNFnameCom, sizeof(MNFnameCom) , Start_Address , &status); while(status != I2C1_MESSAGE_FAIL) { I2C1_MasterWrite(MNFnameCom, 5 , Start_Address , &status); while(status == I2C1_MESSAGE_PENDING); if (status == I2C1_MESSAGE_COMPLETE) break; if (timeOut == SLAVE_I2C_GENERIC_RETRY_MAX) break; else timeOut++; } // SMBus Read I2C1_MasterRead(MNFname ,sizeof(MNFname) ,Start_Address , &status);
} } LA訊號如附檔 address 有輸出但想寫的data都沒輸出
Attach file: (0.00 KB) (0.00 KB)
發表於: 2020/6/1 18:11
|