I'm trying to use the MMA8451Q accelerometer with I2C communication. I don't want to use process expert. I've studied closely the I2C module for kinetics family from the kl25z manuel and the MMA8451Q from the Data Sheet http://www.newark.com/pdfs/techarticles/freescale/MMA8451Q.pdf
I've studied the code generated from process expert, but it uses interruption so it is a little bit different, making the comparison between the programs harder.
My code is attached, it is small, simple and I commented it to help the comprehension. I'm will be really glad to answer any doubts about it. When I run it, my read function only returns 0xff or 0x00 from the I2C0_D, no matter what.
Does anyone has harcoded this before or know what can be wrong with it? I would appreciate any help on that.
Original Attachment has been moved to: main.rar