Page 200 - Embedded Microprocessor Systems Real World Design
P. 200

If you are using an emulator, often there is an external input that you can break-
                 point on. By  connecting the trigger output of  the logic analyzer or DSO to  this
                 external input, you can force a breakpoint.
                   If you are not using an emulator or have no external breakpoint input, you can
                 stop the software by using an otherwise unused interrupt, using a timer as an inter-
                 rupt (see Chapter 5), or even using an NMI. Another possibility is to use the reset
                 input, but you need  a means to keep the software from reinitializing everything
                 after the reset. Using the reset technique will not let you see what the software does
                 after the event, but it will  let you look at the state of the software just before the
                 event.
                   Finally, you can use  this technique to capture the contents of  a rotating trace
                 buffer when a real-world event occurs. If you use any of these techniques to connect
                 a logic analyzer or DSO trigger to your system, be sure the trigger output is com-
                 patible. You  may need  to invert the polarity or change the pulse width to make
                 everything work.



                 Memory Dumps


                 I once worked with a consultant who was interfacing an add-on to our equipment
                 for a third-party reseller. My job was to make sure that nothing we  did or failed to
                 do would keep him from doing his job. This individual had an interface subsystem
                 that consisted of dual microcontrollers communicating via hardware FIFO buffers.
                 Every  now  and  then,  the  entire  thing  would  lock  up  for  no  apparent  reason.
                 He  had  no  tools except  a fairly simple logic  analyzer and  the  stare-at-the-code
                 method  of  debug. At  that  time, no good emulators were  available for  the  pro-
                 cessor he was using. The entire project got so far behind schedule that the reseller
                 sent out its ace troubleshooter to get things going. The troubleshooter was aggres-
                 sively proactive and carried a custom-made wooden briefcase. He even went so far
                 as to order, on the company credit card via overnight delivery, an emulator that
                 was  supposed to be the best there was. That was when we  found out nothing was
                 suitable.
                   The consultant told me that if he could view the internal memory contents, he
                 could fix the problem. We went over an inventory of what he had available, which
                 was  little. The board  had no spare output ports but one unused interrupt input.
                 We  solved the problem by connecting a push-button switch to the interrupt. When
                 the button was pressed, generating an interrupt, the processor produced as output
                 three sync bytes in a sequence that would never occur in normal operation. Then
                 the  processor  sequentially wrote the  entire contents  of  the  internal RAM to  an
                 external  register. The  logic analyzer, connected  to  the register, waited for  these



                 Adding Debug Hardware and Software                                   181
   195   196   197   198   199   200   201   202   203   204   205