General Debugging Tips

There are differing philosophies about debugging, and there is no single correct way to do it. There are things one can do to simplify the process and make it less painful. Embedded systems are a culmination of microprocessor hardware and software. Depending on the complexity of the design, the hardwaremay be a fairly simple "cookbook" design, or a nightmare of state machines and high-speed logic where the firmware plays a minor role in the real-time portion. In either case, the hardware must be working at a minimal level before software debugging can really begin. The debugging process should really be one of proving that the design does what it is supposed to do. There are two methods of doing this: the first one is to plug unproven code into hardware (proven or not), start it up, and see what happens. Bugs are tracked down and stomped one at a time. This method works, but it is prone to leaving undetected errors in the software. A second method of debugging is to verify the hardware as far as is possible with simple routines. Then get a software framework going that can exercise the hardware. Finally, add and verify firmware functions one at a time. The only drawback to this method is that it represents a somewhat idealized picture of the real world. In most designs, you reach a point where you cannot add just one more function and test it.