Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
Need sensor data on frdmK22F board.
Hi, Freescale frdm K22F has FXOS8700CQ accel sensor. My requirement is to read accel x, y & z values. How ever when i read reg 0x0D( who_am_i), it is getting 0, but it should be 0xC7 (as per sensor data sheet).
Here is the code snippet of what i'm trying. This sensor is conneted to MCU with PTB2(SCL) & PTB3 ( SDA).
- define REG_WHO_AM_I 0x0D FXOS8700_sensor::FXOS8700_sensor(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {} uint8_t FXOS8700_sensor::getWhoAmI() { uint8_t who_am_i = 0; readRegs(REG_WHO_AM_I, &who_am_i, 1); return who_am_i; } void FXOS8700_sensor::readRegs(int addr, uint8_t * data, int len) { char t[1] = {addr}; m_i2c.write(m_addr, t, 1, true); m_i2c.read(m_addr, (char *)data, len); }
PinName const SDA = PTB3; PinName const SCL = PTB2;
- define FXOS8700_I2C_ADDRESS (0x1E) Serial pc(USBTX, USBRX); tx, rx FXOS8700_sensor acc(SDA, SCL, FXOS8700_I2C_ADDRESS); pc.printf("FXOS8700 ID: %d\n", acc.getWhoAmI()); ===> It suppose to give 0xC7, however it is giving output 0.
Could some one help what is wrong in this?
I also like to know how can we toggle the pin 34 in MCU? https://developer.mbed.org/platforms/FRDM-K22F/#technical-reference AS per schamatics MCU pin 34 ( RESET) is connected to SEnsor RST line. Do someone can help me with API through which i can toggle this pin? Though i not sure if it will solve this issue, just want to give a try.
Appreciate if someone can help me in this regard.
Thanks, Manish