Page 201 - Embedded Microprocessor Systems Real World Design
P. 201
three bytes (FF FF FF, if memory serves) then triggered and captured everything
that came afterward. The register contents were trashed by this procedure, but
we had to reset everything after the lockup anyway so it did not matter. The
analyzer, like most analyzers, numbered the states. Due to the triggering setup, the
state number was the same as the memory address, so finding a particular byte was
easy.
Another way to handle this, if a spare output port bit is available, is to write a
serial output routine that would transmit the data over the port bit asynchronously
(implementing a bit-banging transmitter in software). The data could be converted
to RS-232 and captured on a dumb terminal or a PC.
Although examining memory may seem like a throwback to the days when main-
frame computers produced what was known as a cm-e dump, the technique can be
very useful, In a simple microcontroller design, there usually is not all that much
memory to examine and only certain locations are important. You can combine
the memory dump with the logic analyzer breakpoint described earlier and capture
the contents of memory when an external event occurs.
Serial Condition Monitor
Sending data to an external logic analyzer typically requires 8 data bits and a write
strobe. In a microcontroller design, especially a small one, not enough 1/0 pins
may be left over to collect diagnostic data. However, if one port pin is available, it
can be used to generate diagnostic information serially. The processor sets the pin
to 1, then serially sends a 4bit diagnostic word. The diagnostic word typically is a
byte in memory, with bits set or reset by various routines to indicate the state of the
code. For example, DO might be set to indicate the state of flow control (ON or
OFF), D1 might indicate when a servo motor is at the home position, D2 tells when
a particular buffer has data to send or receive, and so on.
To use this method, the processor will return the diagnostic once each time it
goes through the polling loop or once each time a regular timer interrupt is ser-
viced. The output data are captured on an oscilloscope or logic analyzer. An oscil-
loscope should be set to trigger on the first sync or start bit. (The start bit is needed
so you can tell which of the other bits are set.) The variable sweep control can be
adjusted so that each output bit takes one or two divisions. This method can be
extended to any number of bits, but trying to do more than about four makes it
difficult to determine which bits are set.
Figure 6.4 shows the waveform that would be generated using this method for
data patterns of 10 (OA hex) and 11 (OB hex). The bits can be captured in a shift
register by using logic that starts on the sync bit and samples in the middle of each
bit.
182 Embedded Microprocessor Systems