Hello Mauricio,
I am giving a software lab course at the University. As students are learning the basics of low-level programming (register level), I do not use Processor Expert in this course. The final experiment is accessing the accelerometer through I2C, so I have developed a library for this purpose, derived from an example library for Kinetis Family, which I simplified and suited for my needs. I am sending the .h and .c files attached to this reply.
For controlling the accelerometer, you just have to write the right values to the right config registers. Remember that the accelerometer address (SlaveID) is 0x1D.
If you just want to read raw (unfiltered) data from XYZ axes, using a full scale range of 2g, you may initialize the accelerometer using this code:
I2CWriteRegister(0x1D, 0x0E, 0x00); // Writes 0x00 to data config register (0x0E).
I2CWriteRegister(0x1D, 0x2A, 0x39); // Writes 0x39 to general config register 1 (0x2A)
Now the accelerometer starts working. It will make a new read (all 3 axes) every 640ms. If you want other periods, you just have to write the right value on 0x2A register, instead of 0x39. For 160ms, write 0x31; for 80ms, write 0x29; for 20ms, write 0x21.
You may read the latest collected values this way:
I2CReadMultiRegisters(0x1D, 0x01, 6, data); // Reads 6 sequential registers starting from MSB of X axis (0x01). "data" is a 6-element array of char.
The result will be the values of 3 axes loaded on "data" array: [MSB_X, LSB_X, MSB_Y, LSB_Y, MSB_Z, LSB_Z]. You may also test if new data is available before reading using:
dr = (I2CReadRegister(0x1D, STATUS) & 0x08); // dr is zero if no new data is available; it is 0x08 if new data is available.
I hope that it helps. Just message me if you need something else.
By the way, Processor Expert should not keep giving you errors. It would be interesting if you could provide more details (including screen captures) about the errors.
Cheers,
Antonio