I'm Road Testing the Rohm SensorShield-EVK-003 (Arduino Compatible) and the sensors that come with it.
In this post, the Accelerometer Sensor .
This post turns out differently than I intended. I was going to test the device directly on a Hercules micro controller, but I have difficulties creating an i2c restart condition on that controller.
I logged a support request for that.
Instead, I have used this post to document and prepare for the exercise, collect the traffic of ROHM's Arduino example, and draw the connections that I'll use when porting to the Hercules.
The KX224-1053 is a little versatile chip. Versatile because it supports both SPI and i2c.
It's sensitive, has an algorithm for free fall (and a few other interesting services, like directional tap and double tap detection), has wake-up, a data buffer and supports interrupts.
It's worth reading the specifications document. The non-basic things that this controller are impressing (e.g: the triggers)
FFI1 – Free fall interrupt reported on physical interrupt INT1
BFI1 – Buffer full interrupt reported on physical interrupt pin INT1
WMI1 – Watermark interrupt reported on physical interrupt pin INT1
DRDYI1 – Data ready interrupt reported on physical interrupt pin INT1
TDTI1 – Tap/Double-TapTM interrupt reported on physical interrupt pin INT1
WUFI1 – Wake-Up (motion detect) interrupt reported on physical interrupt pin INT1
TPI1 – Tilt position interrupt reported on physical interrupt pin INT1
You can combine the X, Y and Z axis via AND and OR logic for some of these interrupts.
You have the possibility to define 2 of them. There are two sets and registers and two physical interrupt pins in the package.
Voltage range from 1.71 to 3.6 V.
Little because it is very small. 3 x 3 mm. Less than a mm high.
The ROHM SensorShield breakout uses i2c. There's little more on the board than the sensor and decoupling capacitors.
Capture Arduino Example i2c Traffic
As first step in getting the sensor to work on another controller, I try to collect the i2c traffic of ROHM's Arduino example.
The example is straightforward. It initialises the sensor, then polls the three axis regularly.
Here's the capture of the initialisation sequence:
And here the protocol to get data, including reading the data for axis X, Y and Z
The traffic looks like the table below. The one I have difficulties with on the Hercules is the restart without stop in row 5.
I2C Analysis results
|Detected bus errors||0|
For the reader, this will very likely be dull info. I hope it helps me with my next exercise ...
Hercules Microcontroller Preparation
I'm going to use a . It's on the high end of the Hercules range.
As explained before, my firmware does not work.
The hardware connection, very simple, should be OK though.
I have everythin wired up and the i2c peripheral properly initiated.
My current status is that I can repeat the whole traffic, except that I have a STOP between line 4 and 5 in the table above.
I have been struggling with this before (and logged unresolved support requests for it). I had another chip that defined a restart, but it gladly ignored the extra stop.
This chip is more demanding and does not give a decent reply when the stop is there.
I don't blame ROHM. Restart is a normal i2c construct. But the Hercules is not an easily tamable controller.
Ironically, the Hercules has a programmable independent timer co-controller on board. I have working code for that co-controller that simulates i2c and supports restart ...