Debug
displays the contents of internal registers as an aid to understanding,
correcting, or modifying programs.
Debug can be a great help in figuring out what's happening inside a running
PBASIC program. You can display the value of any bit, byte, or word of memory
in a window on the PC screen. Of course, Debug depends on the Stamp programming
cable and firmware routines to communicate with the PC. Not every PIC application
will have these luxuries. Here are some suggestions on debugging
assembly-language programs with a minimum of overhead:
-
Run critical portions of your code on the PSIM software simulator. PSIM isn't
perfect, but it will help you catch many errors.
-
Try to reserve at least one I/O pin to drive an LED. Then when you have questions
about the operation of your program, you can devise ways to use the LED to
answer them: Is this subroutine ever getting called? Insert code to light
the LED when the subroutine is called.
-
If your eventual application will use an 18-pin PIC, prototype with a 28-pin
PIC and use port RC to display whole bytes of data on a cluster of LEDs.
For example, you might like to know the value of a variable or the status
register at a given point in the program. Just mov the desired value into
RC and stop program execution with the endless loop jmp $ (jump to here).
-
If your application includes a serial-transmit routine (such as Serout),
get that working first. Then insert calls to tell you the values of critical
variables, registers, etc. The same applies to applications that have displays
of some sort--they can serve as windows into the operation of the rest of
the program.
-
Be careful when you use the skip instruction and related compare-and-skip-if...
instructions (csa, csae, csb, csbe, cse, csne). The instruction to be skipped
must not be more than 1 word long. For example mov fr1,fr2 cannot be skipped,
because it actually consists of two instruction words; the first moves fr2
into w and the second moves w into fr1. If your program tries to skip this
instruction, it will still move w into fr1. Bugs resulting from this can
be hard to trap. The appendix contains a crib she et summarizing all the
Parallax instructions, the number of words they require, and what flags or
registers they affect. Use it to make sure that any instruction to be skipped
has a 1 in the words column.
See also:
file: /Techref/microchip/seepicsrc/psbpix/debug.htm, 2KB, , updated: 2001/1/23 12:09, local time: 2024/11/1 03:33,
|
| ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/microchip/seepicsrc/psbpix/debug.htm"> microchip seepicsrc psbpix debug</A> |
Did you find what you needed?
|