Specifications

Chapter 5 - MPLAB
Previous page Table of contents Chapter overview Next page
5.7 MPSIM Simulator
Simulator is part of MPLAB environment which provides a better insight into the workings of a
microcontroller. Trough a simulator, we can monitor current variable values, register values and
status of port pins. Truthfully, simulator does not have the same value in all programs. If a
program is simple (like the one given here as an example), simulation is not of great importance
because setting port B pins to logic one is not a difficult task. However, simulator can be of great
help with more complicated programs which include timers, different conditions where something
happens and other similar requirements (especially with mathematical operations). Simulation, as
the name indicates "simulates the work of a microcontroller". As microcontroller executes
instructions one by one, simulator is conceived - programmer moves through a program step-by-
step (line-by-line) and follows what goes on with data within a microcontroller. When writing is
completed, it is a good trait to, programmer's first check his program in a simulator, and then
runs it out in a real situation. Unfortunately, as with many other good habits, man overflows this
one too, more or less. Reasons for this are partly personality, and partly lack of good simulators.
First thing we need to do, as in a real situation, is to reset a microcontroller with DEBUG > RUN >
RESET command. This command results in bold line positioned at the beginning of a program, and
program counter is positioned at zero which can be seen in status line (pc: 0x00).
Beginning of program simulation, resetting a microcontroller
One of the main characteristics of a simulator is the ability to view register status within a
microcontroller. These registers are also called special function registers, or SFR registers.
We can get a window with SFR registers by clicking on WINDOW->SPECIAL FUNCTION
REGISTERS, or on SFR icon.
Beside SFR registers, it is useful to have an insight into file registers. Window with file registers
can be opened by clicking on WINDOW->FILE REGISTERS.
http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_07Poglavlje.htm (1 of 2) [4/2/2003 16:18:32]