I'm Road Testing the Rohm SensorShield-EVK-003 (Arduino Compatible) and the sensors that come with it. In this post, the Accelerometer Sensor KX224-1053KX224-1053. 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
Bus configuration | |
---|---|
SDA | Channel 1 |
SCL | Channel 0 |
Statistics | |
Decoded bytes | 44 |
Detected bus errors | 0 |
Index | Time | Hex | Bin | Dec | ASCII |
---|---|---|---|---|---|
0 | 5,00 ns | START | |||
1 | 5,07 μs | 0x3c | 0b00111100 | 60 | < |
2 | 94,56 μs | ACK | |||
3 | 99,70 μs | 0x0f | 0b00001111 | 15 | |
4 | 189,88 μs | ACK | |||
5 | 209,71 μs | START | |||
6 | 214,77 μs | 0x3d | 0b00111101 | 61 | = |
7 | 300,70 μs | ACK | |||
8 | 305,84 μs | 0x2b | 0b00101011 | 43 | + |
9 | 395,02 μs | NACK | |||
10 | 415,90 μs | STOP | |||
11 | 781,35 μs | START | |||
12 | 786,41 μs | 0x3c | 0b00111100 | 60 | < |
13 | 875,84 μs | ACK | |||
14 | 880,97 μs | 0x18 | 0b00011000 | 24 | |
15 | 971,15 μs | ACK | |||
16 | 976,29 μs | 0x40 | 0b01000000 | 64 | @ |
17 | 1,07 ms | ACK | |||
18 | 1,09 ms | STOP | |||
19 | 1,11 ms | START | |||
20 | 1,12 ms | 0x3c | 0b00111100 | 60 | < |
21 | 1,21 ms | ACK | |||
22 | 1,21 ms | 0x1b | 0b00011011 | 27 | |
23 | 1,30 ms | ACK | |||
24 | 1,31 ms | 0x02 | 0b00000010 | 2 | |
25 | 1,40 ms | ACK | |||
26 | 1,42 ms | STOP | |||
27 | 1,43 ms | START | |||
28 | 1,44 ms | 0x3c | 0b00111100 | 60 | < |
29 | 1,52 ms | ACK | |||
30 | 1,53 ms | 0x18 | 0b00011000 | 24 | |
31 | 1,62 ms | ACK | |||
32 | 1,64 ms | START | |||
33 | 1,64 ms | 0x3d | 0b00111101 | 61 | = |
34 | 1,73 ms | ACK | |||
35 | 1,74 ms | 0x40 | 0b01000000 | 64 | @ |
36 | 1,83 ms | NACK | |||
37 | 1,85 ms | STOP | |||
38 | 1,88 ms | START | |||
39 | 1,88 ms | 0x3c | 0b00111100 | 60 | < |
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 TMS570LC43TMS570LC43. 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 ... |