3 Gordon Drive, P.O.Box 1347 Rockland, Maine 04841 U.S.A.
Find Tools for Your Chip


 

© 2004 Avocet Systems, Inc.
Call Us Today at 207-596-7766 ("Picton Press")
Avocet Systems, Inc. : The Complete Solution for Embedded Systems Development Tools
Hints
ICE Background Debugging

Abstract
Some interrupt-intensive embedded applications cannot handle a breakpoint, since stopping the program's code causes interrupts or DMA to be suspended, creating havoc with the hardware. Here's Softaid's solution.

Traditionally, emulators either run the user's program or are idle (i.e., at a breakpoint). Softaid's UEM emulators support give you a third choice - Background mode.

In Background mode the emulator is stopped - that is, a breakpoint has been encountered, and the unit is waiting for action from the operator. However, DMA and interrupts continue to be serviced by the user's program.

Suppose your software controls the motion of a large machine. In most cases a routine will issue an instruction to start it moving, and will service an interrupt when a sensor hits, for example, an end-of-travel limit switch. The interrupt service routine will then stop the motor, halting the machine before it goes too far. While this is a quite reasonable design, it can make debugging with unsophisticated tools a nightmare.

If the code hits a breakpoint while the machine is in motion, the interrupt service routine cannot be invoked until emulation resumes. If the interrupt is used to halt the machine's motion significant damage can result if the machine does not stop as it should!

With the Softaid UEM Background mode, on a breakpoint the emulator stops execution of the main program but continues to run your interrupts. In this example, if a limit switch is hit the interrupt service routine will be started even though the main routine is stopped, halting the machine as required.

In Background mode, interrupt driven time-of-day clocks will stay accurate even when the code is stopped. Similarly, communications controllers that must always queue incoming serial data will continue to receive when in Background mode.

DMA Activity

Some systems use DMA to keep DRAM active or to service communications handlers that constantly transfer data to and from memory. As with interrupts, in Background mode the emulator continues to service these critical DMA requests.

(Even without background mode, all of Softaid's PathFinder and UEM emulators will run DMA cycles from controllers that are part of the CPU chip; DMA from external controllers, though, stops at the breakpoint unless Background mode is enabled.)

What About Trace?

Background Mode has no effect on the emulator's real time trace logic. As always, trace collects data when the program is running. It does not collect if the program is not emulating, nor does it collect on ISRs serviced while stopped in Background mode. This means it won't capture execution of the ISRs that may be running when the main line code is stopped at a breakpoint. Caveats Never use background mode if your interrupt service routines are not completely debugged. Undebugged ISRs may not, for example, return properly after servicing the interrupt. This might cause a program crash.

Do not use Background Mode to debug an ISR. The emulator will disable breakpoints while servicing a background interrupt, so it is impossible to break in the ISR or to single step through it. Either use conventional fully stopped emulation or use the emulator's Real Time Trace to debug the ISRs.

Be wary of using Background Mode if an ISR returns a value in a register (this is unusual, but some applications do work this way). The emulator will reset the registers to their breakpoint value after every Background mode interrupt. To put this another way, if Background mode is enabled and your code hits a breakpoint, the emulator memorizes the registers at the time of the breakpoint, and restores these values before restarting emulation even if the Background interrupts changed them. Real Applications

A Z180 customer in France uses Background mode to debug a punched card reader. The motors in this instrument never stop; they feed cards at an astounding rate all day long, using an ISR to vector cards to different bins. A conventional breakpoint spews cards all over the room! Background mode keeps the unit sorting as programmers debug main line code.

Another customer uses it on an 80186 to synthesize speech. Timer interrupts sequence phoneme generation; though stopped at a breakpoint, the UEM's support of Background interrupts keeps the unit speaking.

One military user services over 15,000 interrupts per second in Background mode to track enemy targets in a virtual gunsight. Even while single stepping through the code, the gunsight's crosshairs continue to follow high- speed targets around the screen.

Copyright 1994, Softaid, Inc.