Hi,
According to the I2C function class document,
read
address 8bit I2C slave address [ addr | 1 ]
so it should be ((0x1D << 1) | 0x01 ) = 0x3B
write
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 ) ;
i2c2.read(0x3B, &v, 1 ) ;
In case it does not work, I'm sorry.
moto
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; pc.baud(115200); i2c2.write(0x1D, &cmd, 1 ); i2c2.read(0x1D, &v, 1 ); pc.printf("received=%d\n",v); }I should received 0x1A and I received 0x4D Here follow the DataAnalyzer picture:
Thanks for your Help Michel