Page 175 - The Art of Designing Embedded Systems
P. 175

162  THE  ART OF  DESIGNING EMBEDDED SYSTEMS


                              matically recovers from the watchdog reset, you surely need some
                              way, during debug, to see that the time-out occurred.
                              When your tools are not working well, or perhaps you’ve simply
                              lost faith in them, you can still track overall program flow by as-
                              signing an 8-bit number to each important function. Output this
                              number to the debug port when the function starts. Collect the data
                              in the logic analyzer and you’ll instantly see what executes when,
                              and for how long.
                              Connect one or more of the more YO bits to LEDs, and instrument
                              the code to signal system state. Most tools do a poor job of read-
                              ing out state; generally you’ll have to stop the code or something
                              similar. The LED bank  instantly  shows things  like, “It’s doing
                              WHAT???!!!!!”
                           If your main debug strategy revolves around a full-blown emulator,
                       if at all possible go ahead and add the BDM or JTAG connector  (if the
                       CPU supports it). The cost is vanishingly small, and the option of doing
                       BDM debugging when the ICE falls flat or fails may save a lot of money
                       and time.
                           Conversely, if a BDM will be the main tool, add a connector (like the
                       Mictor) so that you can connect a logic analyzer for tracking  real-time
                       events. It’s so terribly difficult to use analyzers via their standard multitude
                       of clips that we leave it as a last resort; if it’s easy to connect, we’ll use the
                       tool at the appropriate times.

                           ROM Burnout

                           Remember that every tool affects system operation in some manner.
                       Never wait until the night before shipping to test the system from ROM.
                       Make burning a ROM or loading the Flash a regular part of the test proce-
                       dure.
                              Debugging  tools  invariably  have  a  different  size  of  emulation
                              RAM than your target system’s ROM space (this is true using an
                              ICE or a ROM emulator, or even if you relink your code to run
                              from your system RAM area). If the code grows to exceed target
                              ROM space, it may run just fine from the (probably bigger) emu-
                              lation RAM area.
                             The compiler’s runtime package or constants might be improperly
                              initialized.  Many  C  compilers  require  a  startup procedure  that
                              copies some critical variables to RAM. When you’re debugging,
                              you’ll generally replace system ROM with RAM merely to support
   170   171   172   173   174   175   176   177   178   179   180