I2C drivers and MMA8451 on FRDMK64 (SDK1.3)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C drivers and MMA8451 on FRDMK64 (SDK1.3)

783 Views
Catosh
Contributor IV

I would like to use the MMA8451 with the K64 and kinetis sdk 1_3 on Atollic True Studio. 
For this, I am using the I2C_DRV_MasterSendDataBlocking and I2C_DRV_MasterReceiveDataBlocking drivers provided by NXP.
Probing with the oscilloscope looks like the write and read commands are senti correctly, but I have the wrong reply from the read data. 
Code provided fro reading a single register: 

i2c_status_t MMA8451_ReadReg(uint8_t slave_register, uint8_t *data, short dataSize) {
i2c_status_t res;
uint8_t cmd = slave_register;
res = I2C_DRV_MasterSendDataBlocking(I2C0_IDX,&accel_bus_device,0,0,&cmd,1,5);
res = I2C_DRV_MasterReceiveDataBlocking(I2C0_IDX,&accel_bus_device,0,0,data, 1,5);
return res;
}

Maybe I should take care of the autoincrement? Or the ack and nack and repeated start have to be managed in a different way?
B.R.

L

Labels (1)
0 Kudos
Reply
2 Replies

600 Views
mjbcswitzerland
Specialist V

Hi

If you need a solution for the K64 and MMA8451 (or FXOS8700CQ) you an get it from the Open Source uTasker project. It allows non-blocking I2C operation which will improve efficiency (at the same time as USB, TCP/IP etc.).

Regards

Mark


Kinetis: http://www.uTasker.com/kinetis.html
K64:
- http://www.uTasker.com/kinetis/FRDM-K64F.html    <--- with accelerometer reference
- http://www.uTasker.com/kinetis/TWR-K64F120M.html
- http://www.uTasker.com/kinetis/TEENSY_3.5.html
- http://www.uTasker.com/kinetis/Hexiwear-K64F.html

0 Kudos
Reply

600 Views
Catosh
Contributor IV

Hello Mark, 
Thanks for your quick reply and sorry for my late reply. 
I was looking for a bare-metal implementation, this is why I was focusing on the kinetis sdk. 
BTW, switching to the SDK2.0 on MCUExpresso solved the issue, and I was able to communicate easily with the accelerometer. 
Thanks and B.R.

Luca.

0 Kudos
Reply