0
我一直在測試ADXL345加速計,能夠獲取設備ID以檢查它是否連接正確。現在我試圖在不同的軸上獲得加速度,因爲我不知道寄存器地址不是由於某種原因發送的,所以我無法完成它。寄存器地址在TM4C123GH6PM板上不使用I2C發送
根據該加速度計的數據表中,爲了寫入一字節:
使用的代碼:
void initialize_accelerometer()
{
I2C0_MSA_R |=0x000000A6; //Specify the slave address of the master and that the next operation is a Transmit or write
I2C0_MDR_R=0x2D; //Register address, this is the data not sent
I2C0_MCS_R=0x00000003; // (START, RUN);
while(I2C0_MCS_R&I2C_MCS_BUSBSY){};
if((I2C0_MCS_R&I2C_MCS_ERROR)==0)
{
I2C0_MDR_R=0x08; //Data -> Set power control to measure
I2C0_MCS_R=0x00000005; // (RUN, STOP);
if((I2C0_MCS_R&I2C_MCS_ERROR)==0)
{
set_data_format();
}
}
}
測試與邏輯分析儀,結果如下:
正如你所看到的,所有的都被髮送,但寄存器地址。你能幫我找到錯誤嗎?
感謝, 哈維爾