Skip to main content

Subsection 12.2.4 Part 4: Put the Analyzer on It

The line CoolTerm prints tells us that the read worked, but it does not show us what happened on the two wires. To see the transactions themselves (the address going out, the register number, and the byte coming back), we’ll put the AD2’s logic analyzer on the bus, and we’ll work from that trace for the rest of class.
We’ll put the AD2’s digital leads on the two wires with the same setup we used for the display (Figure 10.3.34 and Figure 12.2.10), with one change: this read takes about 400 µs, so in Waveforms we’ll set the time base to 50 µs per division rather than 20, and drag the view so that the first START is at the left edge.
Figure 12.2.10. Getting the two signals on screen in Waveforms’ logic mode, as for the display, with the time base at 50 µs per division. Four steps: add DIO0 and DIO1 as signals, set the time base, click to make DIO0 falling the trigger, and take a single sweep.

Activity 12.2.3. Predict what the decoder will show.

whoami_test.c is running: once a second, the loop calls lsm303_AccelRegisterRead(), which is one call to i2c1_memRead(). Before you capture anything, predict what the protocol decoder will show for one pass through the loop. How many transactions? What goes out in each one, and what comes back?

Activity 12.2.4. Capture the WHO_AM_I read.

(a)

Take a single sweep. The program repeats the read once a second, so the analyzer captures one within a second of being armed.

(b)

Read your decoded trace and find three things: the device address the decoder prints, the register address, and the value the accelerometer sent back. Compare them with the two #defines at the top of whoami_test.c, open in your own IDE, and with your prediction.
Figure 12.2.14. The WHO_AM_I read, captured and decoded. Two transactions cross the screen: h19 WR, its ACK, the register address h0F, and its ACK, then a repeated START with no STOP before it, then h19 RD, its ACK, the returned h33, a NACK, and the STOP. The decoder marks the repeated START Sr. SCL is DIO1 (green) and SDA is DIO0 (pink), wired as before.
Figure 12.2.16. The same capture, close up: the write transaction (top: the device address and the register address going out), then the read transaction (bottom: the device address again, and the 0x33 coming back, ended by the controller’s NACK).