I2CEngine and NACK on last reading

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I2CEngine and NACK on last reading

918件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elgarbe on Thu Dec 05 18:02:42 MST 2013
Hi, I am using I2C library from lpc175x_6x_cmsis_driver_library_0. It has an I2CEngine routine that make a full I2C transmision, from START to STOP. It function well on 2 programs that I make.
But right now I need to use to interfacing an ADXL345 accelerometer. There is a function that read 6 accel byte data and on las read it need to send an NOACK, CCS C (pic microcontroller):
// Read data from the accel
i2c_start();
i2c_write(ACCEL_WRITE_ADDR);
i2c_write(ACCEL_DATA_ADDR);
i2c_start();
i2c_write(ACCEL_READ_ADDR);
accel_data[0] = i2c_read(); //x0
accel_data[1] = i2c_read(); //x1
accel_data[2] = i2c_read(); //y0
accel_data[3] = i2c_read(); //y1
accel_data[4] = i2c_read(); //z0
accel_data[5] = i2c_read(0); // z1, NACK on last read 


I try it with this code:
I2CWriteLength[PORT_USED] = 2;
I2CReadLength[PORT_USED] = 6;
I2CMasterBuffer[PORT_USED][0] = ACCEL_WRITE_ADDR;
I2CMasterBuffer[PORT_USED][1] = ACCEL_DATA_ADDR;
I2CMasterBuffer[PORT_USED][2] = ACCEL_READ_ADDR;

result=I2CEngine( PORT_USED );


It retreive data for de first time, but I don't know why I always  obtain same value for accel. And more important, I don't know how to tell to I2C library to send a NACK on last reading.

Can any one help me?

Best regards!
ラベル(1)
0 件の賞賛
返信
0 返答(返信)