FSOX8700 acclerometer on the FRDM-K22F

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FSOX8700 acclerometer on the FRDM-K22F

Jump to solution
800 Views
davepfaltzgraff
Senior Contributor I

Is there an application that uses the FSOX8700 accelerometer on the FRDM-K22F board?

I am unable to address the unit on the I2C bus and figure and example or demo would help.

Thanks

Tags (2)
0 Kudos
1 Solution
556 Views
davepfaltzgraff
Senior Contributor I

After trying the code from uTasker and observing the signal levels on an oscilloscope, I determined that the Kinetis ports were not set to open collector. I went back to PE and according to the screen, everything was A-OK. However, affter manually enabling the Open Collector selection for the two port bits, the hardware started responding.

Note: There seems to be some problem in getting PE to synchronize what's displayed and what's generated. It would help if <Auto> was displayed rather than <Enabled> or <Disabled>. <Auto> is not a choice.

View solution in original post

2 Replies
557 Views
davepfaltzgraff
Senior Contributor I

After trying the code from uTasker and observing the signal levels on an oscilloscope, I determined that the Kinetis ports were not set to open collector. I went back to PE and according to the screen, everything was A-OK. However, affter manually enabling the Open Collector selection for the two port bits, the hardware started responding.

Note: There seems to be some problem in getting PE to synchronize what's displayed and what's generated. It would help if <Auto> was displayed rather than <Enabled> or <Disabled>. <Auto> is not a choice.

556 Views
mjbcswitzerland
Specialist V

Hi David

The accelerometer is used in this http://www.utasker.com/kinetis/FRDM-K22F.html (values are displayed or can control a USB mouse).

Beware that the accelerometer has a number of possible I2C addresses that can be configured by pull-up/downs on the board. Specifically you need 0x39 to read it and 0x38 to write it on the FRDM-K22F (where the R/W bit is included in the address - or 0x1c if not). It is only used in MMA8451 compatible mode though but can be set to 14 or 8 bit resolution and use either continuous I2C reading or based on interrupt conversion completion.

I have added a few snippets below  that may help (register values will be fairly clear from the data sheet).

The framework at the link will allows the K22, its I2C operation and the accelerometer to be simulated which makes project development and testing easier.

Note also that the accelerometers don't have a reset line so resetting the processor during transfers can cause the I2C bus to lock up, requiring a power cycle to recover. The I2C driver in the framework incorporates dead-lock detection and recovery.

Regards

Mark

Kinetis: µTasker Kinetis support

K22: µTasker Kinetis FRDM-K22F support / µTasker Kinetis TWR-K22F120M support

For the complete "out-of-the-box" Kinetis experience and faster time to market

static const unsigned char ucSetAccelerometerAddress[] = {FXOS8700_WRITE_ADDRESS, ACC_START_ADDRESS}; // command to set address to read to the start address

static const unsigned char ucReadAccelerometerRegisters[] = {ACC_READ_LENGTH, FXOS8700_READ_ADDRESS, OWN_TASK}; // command to start a read the defined amount of bytes with the task scheduled when the read has completed

static const unsigned char ucSetAccelerometerMode[] = {FXOS8700_WRITE_ADDRESS, ACC_CONTROL_REGISTER, (ACC_CONTROL_REGISTER_ACTIVE | ACC_CONTROL_REGISTER_DATA_RATE_6_25Hz | ACC_CONTROL_REGISTER_SLEEP_RATE_6_25Hz | ACC_CONTROL_REGISTER_LNOISE | ACC_CONTROL_REGISTER_F_READ)}; // command to set the mode

static const unsigned char ucSetAccelerometerRead[] = {FXOS8700_WRITE_ADDRESS, 0}; // command to set address to read to the first register address (status)

static const unsigned char ucReadAccelerometerState[] = {4, FXOS8700_READ_ADDRESS, OWN_TASK}; // command to start a read the defined amount of bytes with the task scheduled when the read has completed

fnWrite(IICPortID, (unsigned char *)ucSetAccelerometerAddress, sizeof(ucSetAccelerometerAddress)); // write the register address to read from

fnRead(IICPortID, (unsigned char *)ucReadAccelerometerRegisters, 0); // start the read process of the required amount of bytes (check the status before beginning)

fnWrite(IICPortID, (unsigned char *)ucSetAccelerometerMode, sizeof(ucSetAccelerometerMode)); // write the operating mode

// Followed by the first status read

//

fnWrite(IICPortID, (unsigned char *)ucSetAccelerometerRead, sizeof(ucSetAccelerometerRead)); // write the register address to read

fnRead(IICPortID, (unsigned char *)ucReadAccelerometerState, 0); // start the read process of the status

// and repeat, or wait for interrupt

0 Kudos