Read an MMA8451

18 Aug 2017

Hello, I was working on my FRDM KL25 with KDS. I want to try MBED online compiler. For that I have made a small program wich read a MMA8451 accelerometer (adress 0x1D) connected on PTE0 and PTE1. For your information, it's working fine with my KDS program. The program is very simple:

#include "mbed.h"
#define REG_WHO_AM_I 0x0D

I2C i2c2(PTE0,PTE1);
Serial pc(USBTX,USBRX);
int main() {
char    v;
char    cmd;
cmd    = REG_WHO_AM_I;
i2c2.write(0x1D, &cmd, 1 );, &v, 1 );

I should received 0x1A and I received 0x4D Here follow the DataAnalyzer picture:


Thanks for your Help Michel

17 Aug 2016

you should use device of softbank.

27 Mar 2017


According to the I2C function class document,
address 8bit I2C slave address [ addr | 1 ]
so it should be ((0x1D << 1) | 0x01 ) = 0x3B

address 8bit I2C slave address [ addr | 0 ]
so it should be ((0x1D << 1) | 0x00) = 0x3A

So why don't you try
i2c2.write(0x3A, &cmd, 1 ) ;, &v, 1 ) ;

In case it does not work, I'm sorry.


29 Mar 2017

Wickr : weeddrop 대마,대마초,떨팝니다,떨판매,확실한인증,수도권떨,서울떨,드랍형식판매 장기거래 가능

Please log in to post a reply.