Page 193 - The Art of Designing Embedded Systems
P. 193
180 THE ART OF DESIGNING EMBEDDED SYSTEMS
This is the trick to effective scope use. A data bus is always ex-
tremely busy. No one is smart enough to drop a probe on it and figure out
what is going on. You must look at the bus at a particular instant in time-
in this case, during the time the I/O write is in process.
In this case, put the chip select on channel 1. Use the trigger controls
to trigger the scope (i.e., start the sweep) when the select comes along.
Thus, select a trigger source of channel 1, and a trigger slope of (-) if the
chip select goes low when it is active (usually the case). Twiddle the trig-
ger level and time/division knobs to get a nice-looking pulse on the screen.
Now, connect the channel 2 probe to a data bus pin on the YO device.
Start with data bit 0. Look at the two signals on the CRT and note the state
of channel 2 when the chip select is active. The data bus might look horri-
ble, with ramping levels and all kinds of nonsense, but during the chip se-
lect period it will be either high or low. Note the state. Check each bit in
succession, logging the pattern.
The result? You’ll find out exactly what data was transferred to the
device, and can use this information to shed some light on what the code
must be doing.
The whole field of digital logic is based on presenting the correct data
at the correct time. When you look at the confusing mess on the scope dis-
play, remember that it really doesn’t matter what is up there, except during
that short period of interest.
You can use this technique to add a “virtual debugging port” to any
embedded system. Sometimes I’ll design a system to include an extra 8-bit
parallel port that drives LEDs. Then I can instrument my program to send
patterns out to the displays, so I can see just what the code is doing. I’ll put
out a different lamp combination for each interrupt service routine, each
main operating mode, etc. If things change so quickly that I can’t see the
LEDs blink, I watch the port with a scope.
The problem is that no boss likes to add special hardware to a system
to ease debugging. One solution is to write the codes out to a nonexistent
port, capturing the data on the scope instead of LEDs.
Frequently the YO decoder has spare outputs; chip selects that were
not needed. Use this unallocated “port” as the virtual debug address. Feed
it into channel 1, and trigger the scope on this signal. Scope the data bus
with channel 2. The YO write to the virtual port will not affect the system,
but it will give you a convenient way to trigger the scope. The data bus’s
contents during the write is the value your instrumented software is send-
ing out.
Chapter 7 describes scopes in general; another very handy attribute of
better oscilloscopes is delayed sweep. Just as any decent scope has at least

