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

66 THE ART OF DESIGNING EMBEDDED SYSTEMS


                           Some, such as the 280, have an external interrupt daisy chain that
                      serves as a priority encoder. Look at these lines with a scope. If you see the
                      daisy chain set to a zero, it’s a sure indication that one device did not see
                      the end-of-interrupt sequence. On the Z80 and Z 180 processors this is pro-
                      vided by executing the RET1 instruction. Use a normal return instruction
                      by mistake and you’ll never get another interrupt.
                           Intel’s  x86 family  is often used  with an 8259 interrupt controller.
                      Some of  the embedded CPUs in this  family have  8259-like controllers
                      built into the processor.  If you forget to issue an EO1 (end of interrupt)
                      command to the 8259 when the ISR is complete, you’ll get that one inter-
                      rupt only.
                           You may need to service the peripherals as well before another in-
                      terrupt comes along. Depending on the part, you may have to read registers
                      in the peripheral to clear the interrupt condition. UARTs and timers usually
                      require this.  Some have peculiar requirements  for clearing the interrupt
                      condition, so be sure to dig deeply into the databook.


                           Finding Missing Interrupts

                           A device that parses a stream of incoming characters will probably
                      crash very obviously if the code misses an interrupt or two. One that counts
                      interrupts from an encoder to measure position  may  only exhibit small
                      precision errors, a tough thing to find and troubleshoot.
                           Having worked on a number of systems using encoders as position
                      sensors, I’ve developed a few tricks over the years to find these missing
                      pulses.
                           You can build  a little circuit  using  a single up/down  counter that
                      counts every interrupt and that decrements the count on each interrupt ac-
                      knowledge. If the counter always shows a value of zero or one, everything
                      is fine.
                           Most engineering labs have counters-test  equipment that just accu-
                      mulates pulse counts. I have a scope that includes a counter. Use two of
                      these, one on the interrupt pin and another on the interrupt acknowledge
                      pin. The counts should always be the same.
                           You can build  a counter by  instrumenting  the ISR  to increment a
                      variable each time it starts. Either show this value on a display, or probe
                      the variable using your debugger.
                           If you know the maximum interrupt rate, use a performance analyzer
                      to measure the maximum time in the ISR. If this exceeds the fastest inter-
                      rupts, there’s very likely a latent problem waiting to pounce.
   74   75   76   77   78   79   80   81   82   83   84