I've been trying to get the accelerometer on the KW40Z development board to work but have had no luck. I have changed the power mode to boost at the moment since the buck and buck auto-start don't supply enough voltage to the accelerometer to turn it on. I keep getting an arbitration lost error when the master tries to communicate to the slave. The master uses the slave address 0x1d or 0x1c (I'm not sure which one when looking at the schematic so I've tried both.). I have used an oscilloscope to verify the P3V3 is at 3V to power the accelerometer which requires a voltage between 1.95V and 3.3V. I have the jumper on J8 so that P3V3 is connected to P3V3_BRD, which powers the accelerometer. The I2C1 status register shows bus busy all the time, which I believe is because the SCL and SDA lines to I2C1 are always at 0V. I have verified this with an oscilloscope attached to J4 pin 10 and 12 according the KW40Z user guide. I have gone to the code in pin_mux.c in function configure_i2c_pins that is supposed to enable the pull up resistors for SCL and SDA on pins PTC2 and PTC3. The line remains low for both SDA and SCL after the code to set pull mode to kPortPullUp has been executed. This code sets the proper registers at PORTC index 2 and 3 for pins 2 and 3. They both get set to 0x307, which enables the pull up resistor. I'm not sure what the problem is since the correct bits are set to pull the line up, but the voltage still remains at 0. I also verified that the correct mux to use is ALT3 for I2C1_SCL and I2C1_SDA on pins PTC2 and PTC3 so as far as I can tell all the correct bits are set int PORTC for pins 2 and 3.
I've attached the i2c_comm demo app that I have modified for KW40Z. I'm using master IAR.
Any help is appreciated. Thank you!
Original Attachment has been moved to: i2c_comm.zip
Solved! Go to Solution.
Update: I thought both of the channels on the oscilloscope I was using were good, but one was bad. Both SCL and SDA on I2C1 are pulled up and working. I tried out I2C0 as well. SCL is high on I2C0, but SDA stays at ~0.8V on I2C0 when P3V3 is set to 3V. I still cannot communicate with the on board accelerometer, but I have an MMA8451 accelerometer on a breakout board from Adafruit. I have connected its SDA and SCL to I2C1 and given it the 3V from P3V3. I can communicate with the accelerometer on the breakout board, but I cannot communicate with the on board accelerometer. I queried the "who am I" register and got back the value 0x1A. This is the MMA8451's who am I value. The FXOS8700CQ's who am I value is 0xC7 so I know I'm not talking to the accelerometer on the board. The accelerometer on the board is actually the FXOS8700CQ, which is a magnetometer combined with an accelerometer. (They both have the same who am I register address.)
Just figured this out by writing this: I was looking at the wrong documentation. The MMA8451 can only have address 0x1c or 0x1d. The FXOS8700CQ can have address 0x1c, 0x1d, 0x1e, or 0x1f. I just talked to the FXOS8700CQ on the board and asked for its who am I value, and it responded with 0xC7. It is working now.