Home

Proteus VSM MPLAB® Viewer

The Integrated Solution for PICMicro™ Development

The Proteus VSM MPLAB viewer provides the link between schematic capture and embedded software development, allowing Proteus VSM to function as a plug-in simulator for the MPLAB IDE. Together with Microchip Technology we have developed a true plug and play solution which enables seamless design flow from schematic capture through software design, compilation, debugging and co-simulation.

Proteus Licensing Options

  • A purchased, professional licence for Proteus VSM will allow you to run the pre-supplied Virtual Evaluation Boards/Application Notes and also to create, edit or otherwise customise any schematic to suit your design requirements.

  • Copies of Proteus which do not have a purchased, professional licence will allow you to load and run pre-supplied Virtual Evaluation Boards/Application Notes but will not allow you to modify the electrical connectivity of the schematic or design custom schematics for your own projects.

You can purchase a professional licence at any time by right clicking in a free area of the viewer and selecting the ‘Buy Full Version Online’ from the resulting context menu.

Using Proteus and MPLAB

  • Why Use the Proteus VSM Viewer?

  • Getting Started with the MPLAB Viewer

  • A Guided Tour of the MPLAB Viewer

  • Taking Measurements and Analysing Data with the MPLAB Viewer

  • Debugging and Diagnostic Tools

  • Limitations of the free Proteus VSM MPLAB Viewer

  • Icon Reference

  • Context Menu Reference

Please email support@labcenter.com with any technical queries or problems.


Context Reference

Proteus VSM MPLAB® Viewer

The Context Menu

The context menu in the Proteus VSM Viewer is accessed via the right mouse button. It acts dynamically, greying out options that are not available, either because the simulation is running or because the option has no meaning at the point where the mouse was clicked. The following summarises the functionality of each option in the context menu.

Open

This presents you with the standard File Open dialogue allowing you to load a different Proteus schematic into the viewer. For your convenience the pre-supplied Evaluation Boards and Application Notes can be accessed directly from the places bar at the left of the dialog box.

Save

This allows you to commit changes to the schematic such as resistance, capacitance values and processor clock frequency. You can change the electrical connectivity of the schematic by launching the schematic application via the ISIS icon.

Save As

This allows you to save the design under a different name. This would typically be used where you were exercising different values for components in an evaluation board or application note and wanted to save several different configurations.

Print

This option will print the schematic (or specified schematic area) using your default printer. It also provides several options for scaling the schematic to paper size and allows configuration of the print job.

Printer Setup

This presents you with the Windows standard Printer Setup dialog form to allow you to configure the print job.

Set Area

Use this option if you want to print only a portion of the schematic. After selecting this option the cursor changes and you can use the mouse to drag out the area you want to print. If you want to deselect a previously specified print area simply re-invoke this command and left click once on the schematic.

Reset Popup Windows

The Proteus VSM viewer will launch popup windows where appropriate for various instruments and peripherals that may be on the schematic (the I2C & SPI protocol analyzers, Oscilloscope and Virtual Terminal amongst others). These can be positioned, resized or indeed closed and re-opened during simulation to maximise screen real estate and the status of each popup is persistent across simulation sessions. This command will reset all the popup windows in a design to their default states.

Reset Persistent Model Data

Proteus VSM models implement persistence of memory (EEPROM for example) exactly as real world devices do. This means for example, that after writing to an I2C memory, the memory contents will persist across simulation runs and MPLAB sessions. All of the persistent model data in the design can be reset globally via this command.

Set Animation Options

This option will launch a configuration dialogue allowing to customise both the appearance of the schematic during simulation and the tolerances and general behaviour of the simulation engine. We would recommend that this be used only by advanced users of the software with a firm understanding of software simulation principles of operation.

Edit Properties

This option, only enabled when the mouse is over a component and the simulation is not running, allows you to change the properties of that component. This can be used for example, to change the capacitance of a capacitor, the resistance of a resistor, the clock frequency of a microprocessor and so on as well as to set the initial values for memories etc.

Operating Point Info

When the simulation is running or paused this options provides a snapshot view of the pin states of the object under the mouse. This option will be disabled/greyed out unless the mouse is over a schematic component and the simulation is either running or paused.

Simulate Graph

This option is enabled when the simulation is not running and the mouse is over a graph object. It will then run a simulation for the time specified on the graph and display the results on the graph after the simulation pass is complete.

Dynamic Simulation Items

Many objects in Proteus (processor models, virtual instruments, EPROM memories etc.) provide access to their internal memory spaces, have their own debugging/trace windows or otherwise produce informative popup windows. These options are obviously dependant on the component being on the schematic and so are dynamic, only becoming visible and selectable when a simulation is in progress.


Diagnostics

Proteus VSM MPLAB® Viewer

Debugging and Diagnostics with the Proteus VSM MPLAB® Viewer

While the ability to execute your code and watch it propagate through your entire embedded system certainly helps verify that your firmware is correct, where Proteus VSM really saves you time is when something is not working correctly and you need to isolate and correct the problem. The following discussion details some of the debugging techniques available to you within the Proteus VSM MPLAB viewer.

Basic Debugging Tools

One way to think of the viewer is as a ‘Virtual ICE’ where the hardware is presented to you as a schematic instead of a physical prototype. This means that Proteus is slaved to the MPLAB environment and you can single step your code in MPLAB, monitoring the effects of code execution on the schematic. Better still, because you are working in a software environment the entire system will ‘freeze’ in time after every step (without the associated problems such as capacitors discharging that would occur in a physical prototype).

The following guide will cover the basics of single stepping and code navigation of a system level simulation as well as detailing the procedure for injecting values directly into the system via the MPLAB environment. Prior to starting this walkthrough you should have the ‘Explorer16’ workspace with associated schematic loaded inside the MPLAB environment.

Single Stepping and Value Injection with Proteus and MPLAB

1. Start by Connecting the simulation to the MPLAB environment via the green button at the top right of MPLAB.

2. Note that at this point the simulation has connected but no simulation time has elapsed. This is shown on the status bar at the bottom of the Proteus VSM Viewer.

3. To take a closer look at what is happening we can set breakpoints and single step within MPLAB. Try this now by launching the eeprom.c file and and double clicking in the grey area just inside the EEPromWriteByte() routine.

4. Having set a breakpoint we can now run the simulation via the Play button at the top of the MPLAB IDE. If you then hit the S4 button to change mode and then hit the S5 button to write the current temperature to the EEPROM the breakpoint will trigger and the entire system will pause in time.

5. To monitor the effects of stepping the code right click in an empty area of the schematic and select SPI Memory – Internal Memory from the resulting context menu. This will launch a popup containing the memory contents of the EEPROM which you can then position in a suitable area of the IDE.

6. Finally, use the F8 key (or the Step Over command on the Debug Menu) to step the code and watch the transmitted data appear in the EEPROM memory (starting at address 0x0000). Use the small cross at the top right of the popup window to close it when you are finished.

7. Now let’s have a look at how to inject a value directly into the simulation from the MPLAB IDE. Make sure that the system is paused by checking the status bar at the bottom of the Proteus VSM Viewer and using the Halt command on the Debugger Menu if the simulation is currently running.Go to the View Menu in MPLAB and select the Special Function Registers menu item.

8. Scroll down to find the TRISA register, left click on the Hex column and type 0x0000, thus setting the port to be an output. Now find the PORTA register and set the value to be 0x00FF for example.

9. On applying this value to PORTA you should see that all the LED’s at the bottom of the schematic (which are connected to the PORTA pins) have now lit up. What we have effectively done is injected stimuli to the circuit without advancing the processor clock – no instructions have executed during this operation. This is an extremely useful technique where we want to see the effects on our code of specific register conditions (a timer overflow for example).

10. Use the red button at the top right of the MPLAB IDE to stop the simulation and disconnect Proteus from MPLAB when you are finished.

Diagnostic Tools

Diagnostic tools (sometimes known as trace modes) provide a powerful method of interrogating parts of the system during simulation. Essentially what you do is specify the on-board or system peripheral(s) that you want to monitor and you then receive a detailed textual report as the simulation progresses, informing you of all activity on these peripherals. Think of this as ‘lifting the lid’ on a component to better see what is happening as the simulation progresses.

The following example shows how to configure diagnostic reporting for the PICmicros™ ADC module. You can of course interrogate any on-board peripheral (as well as system peripherals!) in exactly the same way. Start by loading the Explorer16 project and schematic into the MPLAB viewer from the Samples/Microchip directory of your installation. See the Getting Started section of the documentation for more information.

Using Diagnostic Tools and the Simulation Advisor

1. Launch the configure diagnostics tool from the Proteus VSM Viewer.

2. Select ADC Events and set to Full Trace mode.

3. Close the dialogue form and connect Proteus to the MPLAB IDE.

4. Launch the Simulation Advisor from the bottom right of the Proteus VSM viewer and position in a free area of the workspace.

5. Start and run the simulation and then stimulate the schematic such that an ADC conversion occurs (for example, press the S4 button to enter temperature/voltage mode and then adjust the temperature on the TC1047A).

6. You should be able to see that all ADC events are logged in the simulation advisor.

7. When you are finished disconnect the simulation from the MPLAB IDE.


GettingStarted

Proteus VSM MPLAB® Viewer

Getting Started with the Proteus VSM MPLAB® Viewer

A number of Microchip™ application notes and evaluation boards have been created in Proteus VSM and come pre-supplied and ready to use with the Proteus software. The following example provides a ‘getting started’ guide to configuring Proteus to work with MPLAB®.

Loading and Running a Proteus VSM simulation on the Explorer16 Evaluation Board :

1. (by default this will be c:\program files\Labcenter Electronics\Proteus 7 Demonstration\Samples\) and then the VSM MPLAB Viewer\Eval Boards\Explorer16 with PIC24FJ128GA010 directory. Finally, open the PIC24ExplDemo.mcw workspace.

2. Go to the Debugger Menu in the MPLAB IDE, select the Select Tool command and then Proteus VSM. This configures MPLAB to use Proteus as the tool of choice for debugging.

3. You should now see that the Proteus VSM Viewer has opened inside MPLAB. Use the Open Icon on the viewer and select the Explorer 16 schematic from the resulting file selector.

4. Select the Build All command from the Project Menu to ensure that our project code is both compiled and ready for simulation.

5. Now that we have the schematic and project we can start the simulation. Use the green button at the top of the MPLAB IDE to connect the Proteus simulation to MPLAB.

6. At this point the simulation is paused at time zero. Start the Simulation by clicking on the Play button near the top right of the MPLAB IDE. This will execute the program code and the VSM Viewer will show you the effects of your program on the design.

7. Use the red button at the top of the MPLAB IDE to disconnect the VSM Viewer from MPLAB and stop the simulation.

  • Note that, because the PIC24 is a large part it has been placed on a second sheet on the schematic and the connection to and from the processor are made via terminals. See the section on schematic navigation for more information.

While there is clear benefit from exercising our code through a virtual system (we can tell immediately that our LCD routines are working correctly for example) there is far more to working with Proteus and MPLAB than simply free running a simulation. The following topics include practical examples with the Explorer 16 board you currently have loaded and we recommend you work through them.

Measurement and Analysis with the Proteus VSM Viewer

Debugging and Diagnostics with the Proteus VSM Viewer

Additional functionality of the Professional Proteus VSM Viewer

You may also wish to experiment with the other pre-supplied schematics (for example, the PICDEM 2+ Evaluation Board or the Microchip Application Notes. Remember, you can design your own code projects and test them fully with the Proteus VSM viewer but you need to purchase a full professional version in order to create your own schematics.


GuidedTour

Proteus VSM MPLAB® Viewer

A Guided Tour of the Proteus VSM MPLAB® Viewer

The Proteus VSM MPLAB viewer is designed to allow you to simulate and interact with Proteus schematics inside MPLAB. It is fully functional as a viewer, providing everyone with the ability to run and debug with pre-supplied application notes and virtual evaluation boards. Editing functionality however, is available only to licensed users of the Proteus VSM software, who can therefore design and test their own projects.

The following discussion provides a broad overview on working with a schematic inside the Proteus VSM viewer - details on loading the pre-supplied schematics into the viewer can be found here

Context Menus

As with almost all Windows applications most actions on the viewer can be accessed via the right mouse context menus. These allow you to place measurement instruments, edit component properties, launch simulation windows, navigate through sheets and so on. Context menus are dynamic in the viewer so, for example, when you right click over a component you have an option to edit the components properties and when you right click in a free area of the schematic you can navigate sheets.

Additionally, the options available to you when Proteus is connected to MPLAB are different from those presented to you when a simulation is not in progress. This makes sense as, for example, it would not be a good idea to allow you to delete the PICmicro™ from the schematic during a simulation and would be similarly pointless to launch a popup window showing the contents of an I2C memory when the schematic is disconnected from MPLAB.

  • In particular, note that to place and wire virtual instruments or to edit component values requires that Proteus is disconnected from the MPLAB environment.

  • It is not possible to edit the connectivity of the schematic (for example, rewiring an existing circuit or creating your own schematics) without a professional licence for Proteus VSM. Once purchased, you can both create your own designs and modify the connectivity of existing schematics.

Navigating the Schematic

Once we have a schematic loaded in the viewer we need to be able to navigate around the schematic and view certain portions of it as required. This typically falls into two categories; navigating within a sheet on the schematic and navigating across sheets on the schematic.

Navigating Within a Sheet

This is by far the most common type of navigation, where you want to zoom into (or out of) a particular area of the current sheet or re-centre the display on a portion of the schematic.

You can change the display of a sheet in one of the following four ways:

1. Use the Zoom In and Zoom Out icons to change the magnification of the current view. This will change the magnification but not re-centre the display.

2. Use the Pan icon to re-centre the display at the current magnification at the point subsequently selected by the mouse button.

3. Click the middle mouse button and then move the mouse. This will ‘pick up’ the entire schematic and re-centre according to the motions of the mouse. You can also roll the middle mouse wheel during this operation to simultaneously zoom and pan. Left click the middle mouse button when you are finished to exit ‘track pan’ mode.

4. Zoom in and out with the mouse wheel. This has the advantages of being quick and also that the display will re-centre around the current cursor position.

5. Zoom in to a particular area of the board by selecting the Zoom to Area icon and dragging out an area of the schematic (left depress the mouse and drag). Holding the SHIFT key down and left dragging the mouse will have the same effect.

You can re-centre the display and magnification such that the entire sheet is visible in the viewer at any time via the Zoom to Sheet icon.

All the icons referenced above are detailed here.

Navigating Between Sheets

With more complicated, hierarchical schematics, it is sometimes necessary to navigate between sheets on the schematic. This is achieved via the sheet navigation icons at the top of the viewer or by right clicking in a free area of the schematic and selecting the sheet from the resulting context menu as shown below.

Navigating to a Sheet via the Context Menu.

Configuring a Schematic Prior to Simulation

You will almost certainly want to edit component values prior to starting the simulation (if only to set the correct clock frequency for the processor!!) and the Proteus VSM viewer allows you to do this as follows :

To Edit a Component Value:

1. Make sure that a simulation is not in progress (see the screenshot below) and move the mouse over the component to be edited.

2. Right click on the component and select edit properties from the context menu.

3. From the resulting dialog box change values as required. For example, with a processor you can specify the clock frequency, with a resistor change the resistance, with a terminal the baud rate and so on.

4. Hit the OK button on the dialog to commit the change.

  1. Full customisation of schematics is possible with a professional version of the Proteus software, where you can use the ISIS icon to modify the connectivity of the schematic.

Running a Simulation

Having arranged the display and edited the component values as required we now want to run a simulation. This is done in MPLAB either via the connection icons as shown below, via the Start Simulation command on the Debugger window or via the F12 shortcut key.

The simulation status icons both when stopped (left) and when simulating (right).

The simulation will start up and pause immediately (before any simulation time has elapsed). This allows you to move popup windows, set breakpoints in MPLAB and otherwise set up your debugging environment prior to setting the simulation free running. The Run command from the Debugger menu or the F9 shortcut key can then be used to set the simulation going.

When the simulation is running the viewer acts as your virtual testbench. This means that you can use the mouse to hit buttons, flick switches, adjust gain on pots, temperature on thermostats and so on. You can also use the keypad model, virtual terminal or indeed analog & digital generators to provide a command interface or stimulus to your program (provided the schematic contains these parts of course!).

The debugging interface is identical as that for a standard MPLAB session – start/step/run etc. along with the MPLAB watch window and debugging windows can all be used exactly as normal. Please see the MPLAB help documentation or the section on debugging techniques for more details.

Managing Screen Real Estate During Simulation

When the simulation is running you may end up with a plethora of popup windows for the various debugging tools and information displays available to you. These can all be moved to anywhere within the MPLAB IDE and will remember their positions between simulation sessions. Alternatively, they can all be closed via the cross at the top right of their window and re-opened via the simulation icons or via the right mouse context menu as required.


IconReference

Proteus VSM MPLAB® Viewer

Icon Reference

While the general operation of the Proteus VSM Viewer is intuitive and straightforward we have listed the icons available together with a brief description of what they do below:

Open Icon

This icon will launch the Open File dialogue form allowing you to load a different Proteus schematic into the viewer. For your convenience the pre-supplied Evaluation Boards and Application Notes can be accessed directly from the places bar at the left of the dialog box.

This option is only enabled when a simulation is not in progress.

Save Icon

This allows you to commit changes to the schematic such as resistance, capacitance values and processor clock frequency. If you are using a pre-supplied virtual evaluation board or application note you will be prompted to save the design under a different name.

This option is only enabled when a simulation is not in progress.

Print Icon

This option will print the currently loaded schematic or a specific area of the schematic if specified by the user. The resulting dialog also provides several options for scaling the schematic to paper size and allows configuration of the print job.

Printable Area Icon

By default a print action will print the entire schematic. If, however, you only want to print a specific section of the schematic use this command. The cursor will then change and you can use the mouse to drag out the area you want to print. If you want to deselect a previously specified print area simply re-invoke this command and left click once on the schematic.

ISIS Icon

This option will launch a copy of the ISIS schematic capture package with the design currently in the viewer preloaded. Users can then edit, delete, rewire or otherwise the schematic to suit the requirements of their current project. Saving the design in ISIS will then cause the viewer to reload the now modified schematic.

If you invoke the ISIS package and make changes while a simulation is running on the viewer, the simulation will automatically stop when you commit the changes in order that the newly modified schematic can be loaded into the viewer.

This option is limited to licensed professional users of the Proteus software as a professional version of the capture package (ISIS) is necessary to modify the connectivity of designs.

Configuration Diagnostics

This option will launch the configure diagnostics dialogue form, allowing you to specify diagnostic reporting for peripherals of interest on the current schematic design. More information on diagnostics can be found here.

Help Icon

Selecting this option will launch this help file.

Pan Icon

This icon is used for navigating around the schematic, and specifically for repositioning the display on a different portion of the schematic. After selecting this icon left click on the point on the schematic on which you would like the viewer to centre it’s display. This command together with the zoom commands detailed below provides complete control over the display area.

Zoom In Icon

This icon allows you to increase the magnification on the schematic. Note that this will zoom in around the current centre of the schematic - you can use the Zoom to Area command detailed below to zoom in on a particular section of the schematic.

You can also use the mouse wheel to zoom in (or out) of the area pointed to by the mouse.

Zoom Out Icon

This icon allows you to decrease the magnification on the schematic. Note that this will zoom out around the current centre of the schematic - you can use the Zoom to Area command detailed below to zoom in on a particular section of the schematic.

You can also use the mouse wheel to zoom out (or in) of the area pointed to by the mouse.

Zoom to Sheet Icon

This icon will reset the magnification and re-centre the schematic such that the complete schematic is visible on the viewer screen.

Zoom to Area Icon

This icon is used to zoom in on a specific area of the schematic, both increasing the magnification and centring the display around the selected area. When invoked the cursor will change and you can then drag out the area you want to zoom in to with the left mouse button.

You can also zoom in on a particular area of the schematic by holding down the SHIFT key on the keyboard and dragging the area out with the left mouse button.

Goto Sheet Icon

This command will launch a dialog form which enables you to navigate between different sheets on a hierarchical design.

Enter Child Sheet Icon

This command allows you to enter a specific child sheer on a hierarchical design. After invoking the command, the cursor will change and left clicking the mouse on the parent component will switch the view to the child sheet for that component.

Exit to Parent Sheet Icon

This command will exit the current child sheet in an hierarchical design and switch the viewer display back to the parent sheet.

Simulation Log Icon

This icon will launch the Proteus VSM simulation log, which contains a wealth of information on the state of a simulation as well as providing warnings of net contentions and other diagnostic information.

This option is only enabled when a simulation is in progress.

Watch Window Icon

This command will launch the Proteus VSM watch window. Right clicking on the watch will then allow you to add items from the processors memory spaces (and internal data structures) for monitoring.

You can add a watchpoint condition via the context menu on the watch window, specifying a condition on a watch window item which, when satisfied, will cause the simulation to pause. This is an extremely powerful debugging tool. For example, to pause the simulation when a timer overflows or when a specific value is written to a port.

Items can be dragged and dropped onto the watch window from any other memory window launched on the viewer. This means for example that you could launch the I2C memories memory contents, highlight a memory address and drag it onto the watch window and then visually monitor it as the simulation progresses.

This option is only enabled when a simulation is in progress.

Virtual Oscilloscope Icon

This icon allows you to launch the Virtual Oscilloscope for analysis during a simulation.

This option is only enabled when a simulation is in progress and an oscilloscope is present on the schematic.

Logic Analyser Icon

This icon allows you to launch the Virtual Logic Analyser for analysis during a simulation.

This option is only enabled when a simulation is in progress and a Logic Analyser is present on the schematic.

Virtual Terminal Icon

This icon allows you to launch the Virtual Terminal during a simulation.

This option is only enabled when a simulation is in progress and a Virtual Terminal has been placed on the schematic.

I2C Protocol Analyser Icon

This icon allows you to launch the I2C Protocol Analyser for analyses during a simulation.

This option is only enabled when a simulation is in progress and an I2C Protocol Analyser has been placed on the schematic.

SPI Protocol Analyser

This icon allows you to launch the SPI Protocol Analyser for analyses during a simulation.

This option is only enabled when a simulation is in progress and an SPI Protocol Analyser has been placed on the schematic.


Limitations

Proteus VSM MPLAB® Viewer

Limitations of the Proteus VSM MPLAB® Viewer

The main limitation of the Proteus VSM viewer is that you cannot directly change the connectivity of schematic of schematics within the viewer. That is, while you can adjust component values and properties you cannot, for example, rewire an LCD onto a different port.

This limitation does not apply where the user has a professional license for the Proteus VSM software as they can launch the ISIS schematic capture editor (via the ISIS icon) and thereby have full control over the schematic.

This is summarised below :

  • Ability to exercise code through a complete virtual system.

  • Ability to change component values (e.g resistances, capacitances, clock frequency, etc.).

  • Ability to place measurement instruments (e.g. oscilloscope) and analyse data.

  • Ability to single step debug both hardware and software synchronously in time.

  • Ability to interrogate devices to receive diagnostic reporting as the simulation progresses.

  • Ability to use and simulate all pre-supplied Microchip Evaluation Boards and App Notes.

  • Ability to edit the connectivity or rewire an existing schematic.

  • Ability to create a custom schematic tailored to your current project.

Where:

  • Available with the Viewer.

  • Requires Professional Licence.

You can purchase a professional licence at any time by right clicking in a free area of the viewer and selecting the ‘Buy Full Version Online’ from the resulting context menu.


Measurements

Proteus VSM MPLAB® Viewer

Taking Measurements with the Proteus VSM MPLAB® Viewer

You can place and wire a number of virtual instruments onto the schematic from within the Proteus VSM viewer, allowing you to interrogate the virtual system during simulation. The full list of available instruments is provided below.

  • Oscilloscope

  • Logic Analyser

  • Counter/Timer

  • Signal Generator

  • Pattern Generator

  • Dual Mode I2C Protocol Analyser

  • Dual Mode SPI Protocol Analyser

  • TTY/RS232 Virtual Terminal

  • DC/AC Voltmeters and Ammeters

  • Voltage and Current Probes

Each instrument has a help file associated with it which can be launched by right clicking on the component (once placed), selecting Edit Properties from the resulting context menu, and then hitting the Help button at the right of the resulting dialogue form. This help file explains all the modes of operation for the instrument and provides a useful reference source in correct operation.

Accessing the Model Help File (Note - Simulation must be stopped).

It is important to realise that all pulses, signals and waveforms propagate through the wires on the schematic – there is no cheating or hidden communication between components. This means that you can place and wire any instrument at any place on the schematic to interrogate the design at that point.

Placing instrumentation is extremely simple and an example is detailed below. The following walkthrough assumes you have the Explorer 16 evaluation board loaded with the PIC24ExplDemo.mcw workspace – please see the Getting Started section for details.

Using Virtual Instrumentation to Analyse SPI Transmissions

1. Right click the mouse on a free area of the schematic and select Place - Instrument - SPI Debugger from the resulting context menu.

2. You should now see an outline of the instrument that will follow the mouse pointer around the viewer. Position the mouse pointer just below and to the right of the SPI Memory device and left click to commit placement.

3. Having now placed the analyser we need to wire it up. Start by hovering the mouse over the DIN pin. The mouse curser should change to be a green pencil indicating that we can start a wire from this point.

4. Left click to enter wire placement mode and then move the mouse up to the wire beside the SO Pin of the SPI memory, left clicking again (when the mouse cursor turns green) to complete the wire placement.

5. Repeat the procedure with the DOUT, SCK and SS pins of the SPI debugger, wiring them onto the SI, SCK and CS lines respectively as shown below.

6. Now that we have wired the SPI Debugger we can run the simulation and monitor traffic on the bus. Use the green button to connect and then the play button to start the simulation running.

7. In order to write to the SPI memory we must first switch into temperature/voltage mode via the S4 button at the left of the schematic and then use the S5 button to write the current temperature to the SPI memory.

You may want to pause the simulation and resize the Protocol Debugger at this point to better interrogate the data. You should see that the SPI Debugger looks something like the screenshot below.

For reference, the command codes for communicating with the 25LC256 SPI Memory are given below :

Name | Format | Description
READ | 0000 0011 | Read data from memory array beginning at selected address
WRITE | 0000 0010 | Write data to memory array beginning at selected address
WRDI | 0000 0100 | Reset the write enable latch (disable write operations)
WREN | 0000 0110 | Set the write enable latch (enable write operations)
RDSR | 0000 0101 | Read STATUS register
WRSR | 0000 0001 | Write STATUS register

Given this, together with some basic knowledge of the SPI protocol, we can interpret our display as follows :

  1. The SS pin is driven high and an 0x06 is transmitted which sets the write enable latch.
  2. Because SPI is a duplex protocol we receive a byte back which is effectively noise.
  3. The SS pin is then toggled low and high and a write sequence is sent. The first byte is 0x02 to specify the write, the following two bytes specify the address (0x0000 in this case) and the last byte is the data (0x01 in our example).
  4. Again we receive 4 bytes back which we are not interested in.
  5. The SS pin is toggled again and a status read is then requested from the SPI memory. A status read is a 0x05 - we must send a second 'dummy' byte in order to receive the status back!
  6. Data 0x03 is received back from the SPI memory which means that the SPI is currently busy. This polling sequence is repeated until we receive a 0x00 back from the SPI memory.
  7. Steps 1) to 6) are then repeated with the second byte that we want to store. Note that this time, the address is 0x0001 and the data (in our case) is 0x0E.

To summarise, we have now written 0x010E starting at address 0x0000.0x010E corresponds to 270 decimal which in turn corresponds to the current temperature of 27.0 degrees.

Temperature Sensor on the Schematic.

  • You can further verify that the write has been successful by right clicking in a free area of the schematic and selecting 'SPI Internal Memory' from the resulting context menu. You should see that the specified data is in the memory at the correct address.

  • Note that, in this example we have used the SPI protocol analyser simply as a monitor for the bus. Both the SPI and the I2C protocol analysers are capable of acting as monitors, master devices or slave devices. See the help files for the instrument (as detailed above) for more information.


WhyUse

Proteus VSM MPLAB® Viewer

Why Use the Proteus VSM MPLAB® Viewer ?

The Proteus VSM Viewer can be thought of as a Virtual Prototyping Environment, effectively simulating your firmware on a schematic version of the complete embedded system. The Proteus PICmicro™ models run the exact same binary as that you would use to program a physical chip and all signals propagate through the wires on the schematic. This means that you can realistically design, test and debug both the firmware and the hardware prior to physical prototyping

Using the Proteus VSM viewer with MPLAB has numerous advantages over traditional development techniques. These broadly fall into the following categories :

Price

When you consider that Proteus VSM includes over a dozen instruments, including a DSO, Logic Analyzer and I2C/SPI Protocol Analyzer, as well as a world class schematic and simulation environment, the cost of a full professional licence is a fraction of that for equipping an equivalent hardware lab.

Flexibility

Because you are working in a software environment it is the matter of minutes to rewire your schematic, change your firmware and retest. If you want to optimise or experiment with your hardware (or software!) design prior to prototyping you can do so quickly and in a transparent environment where the results of your mods can be seen instantly.

Changes to hardware design are as simple to make as changes to software design and the verification of changes (by running the simulation) is easy and fast.

Unique Features

Proteus VSM includes a number of features that either can’t be done or can’t be done easily in a hardware environment. For example,

  • Diagnostic messaging allows you to interrogate system components such that you receive a live textual report on all interaction between that component or peripheral and the rest of the system.

  • The Proteus simulation engine will monitor your system during simulation and automatically warn you of common hardware and software errors such as timing or logic contentions between system components, writing to illegal memory addresses or trashing the stack in your firmware, etc.

  • When you set a breakpoint or pause the simulation the entire system freezes in time. This means, for example, that unlike a hardware environment your capacitors won’t discharge, your motor won’t keep spinning and lose momentum, etc. When you single step debug the PICmicro™ model will execute the instruction stepped over, the effects of that instruction will propagate through the entire design and the system will then freeze in time.

  • Testing of firmware interaction with the system is easy and obvious. If, for example, you want to test that your temperature sensor code, you simply adjust the temperature on the peripheral and examine the response of the firmware. Compare this with the equivalent effort in a hardware prototyping environment.

Timesaving Costs

All of the above mean that it’s easier to test, analyse and debug, that’s it’s easier to modify and correct and that it allows you to rapidly advance project design. This is the VSM advantage.