AnsweredAssumed Answered

MMA955L pedometer issue in reading 6axis data

Question asked by Prasanna Prabhu S on Feb 26, 2016
Latest reply on Jul 27, 2017 by Chiranjeevi Kinnera

I am using MMA955l pedometer sensor in STM32l4RTC MCU, which is connected to i2c and I need to read accelerometer data from chip. I did not find any sample source and going through datasheet and looking at examples I am following command sequence as :

   aTxBuffer[0] = 0x00;

  aTxBuffer[1] = 0x00;

  aTxBuffer[2] = 0x00;

  aTxBuffer[3] = 0x0C;

  MMA955L_AcclDataTx(aTxBuffer, 4); //Read ID command

 

//Read Pedometer ID

MMA955L_AcclDataRx(aRxBuffer, 16);

Note: I get response as :

0x00 0x80 0x0c 0x0c 0x7a 0xed 0x25 0x5d 0x01 0x01 0x02 0x02 0x01 0x06 0x03 0x41 when I read 16 bytes of data.

 

//command to request_to_start register configuration

aTxBuffer[0] = 0x01;

  aTxBuffer[1] = 0x10;

  aTxBuffer[2] = 0x00;

  aTxBuffer[3] = 0x04;

  MMA955L_AcclDataTx(aTxBuffer, 4);

aTxBuffer[0] = 0x01;

  aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x00;

  aTxBuffer[3] = 0x04;

  aTxBuffer[4] = 0xAA;

  aTxBuffer[5] = 0xBB;

  aTxBuffer[6] = 0xCC;

  aTxBuffer[7] = 0xDD;

  HAL_Delay(100);

  MMA955L_AcclDataTx(aTxBuffer, 8);

 

//Interrupt_App_IDs register configuration

aTxBuffer[0] = 0x01;

aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x0C ;

  aTxBuffer[3] = 0x04;

  aTxBuffer[4] = 0x06;

  aTxBuffer[5] = 0x00;

  aTxBuffer[6] = 0x00;

aTxBuffer[7] = 0x00;

  MMA955L_AcclDataTx(aTxBuffer, 8);

//Awake accelerometer

 

aTxBuffer[0] = 0x12;

  aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x06;

  aTxBuffer[3] = 0x01;

  aTxBuffer[4] = 0x00;

MMA955L_AcclDataTx(aTxBuffer, 5);

 

//Put accel in legacy mode

aTxBuffer[0] = 0x18;

  aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x00;

  aTxBuffer[3] = 0x01;

  aTxBuffer[4] = 0x10;

MMA955L_AcclDataTx(aTxBuffer, 5);

 

//Configure accelerometer xyz data

aTxBuffer[0] = 0x4;

  aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x00;

  aTxBuffer[3] = 0xC;

  aTxBuffer[4] = 0x06;

  aTxBuffer[5] = 0x00;

  aTxBuffer[6] = 0x06;

  aTxBuffer[7] = 0x01;

  aTxBuffer[8] = 0x06;

  aTxBuffer[9] = 0x02;

  aTxBuffer[10] = 0x06;

  aTxBuffer[11] = 0x03;

  aTxBuffer[12] = 0x06;

  aTxBuffer[13] = 0x04;

  aTxBuffer[14] = 0x06;

aTxBuffer[15] = 0x05;

   MMA955L_AcclDataTx(aTxBuffer, 16);

//Reading aggregated data

aTxBuffer[0] = 0x12;

  aTxBuffer[1] = 0x20;

  aTxBuffer[2] = 0x06;

  aTxBuffer[3] = 0x01;

  aTxBuffer[4] = 0x00;

  MMA955L_AcclDataTx(aTxBuffer, 5);

 

//POst this read 6 bytes data

MMA955L_AcclDataRx(aRxBuffer, 6);

Note: Getting reply as 0x00 0x80 0x0c 0x0c 0x7a 0xed

 

Is that I am following proper steps or is that I need to change any ?

info : Here MMA955L_AcclDataTx is a function to transmit data to i2c slave and MMA955L_AcclDataRx is a function to receive i2c data from slave.

 

Regards,

Prasanna Prabhu

Outcomes