Microcontroller Unit Co-Simulation for SPICE-Based Circuits in NI Multisim

Publish Date: Aug 01, 2017 | 38 Ratings | 3.32 out of 5 | Print | 3 Customer Reviews | Submit your review

Table of Contents

  1. Overview
  2. Before You Begin
  3. Create A New MCU Project
  4. Enter Source Code And Additional Project
  5. Place And Wire Peripheral Components
  6. Simulate Your Circuit
  7. Debug Your Source Code
  8. Switch Between Active Projects
  9. Additional Resources

1. Overview

National Instruments Multisim now has microcontroller unit co-simulation capabilities, allowing you to include a microcontroller, programmed in assembly or C code, within your SPICE modeled circuit.

The MCU functionality in Multisim  enables students, educators and professional users to program MCU's in assembly or C language within the familiar Multisim environment. The MCU capability can be used with any of Multisim’s virtual instruments for a complete system simulation, including the microcontroller and all connected analog and digital SPICE components.

The MCU Module supports Intel®/Atmel® 8051/8052 and Microchip PIC16F84a chips as well as a broad range of advanced peripherals like external RAM and ROM, keypads, graphical and alphanumeric LCDs and others. The MCU Module takes full advantage of the Multisim educational platform which makes it the ideal choice for courses such as digital electronics, computer architecture, MCU programming, embedded control, senior design and more!


Back to Top

2. Before You Begin

The attached archive contains all files necessary to complete this tutorial. However, this tutorial is showing how to create an MCU Module project from scratch, with the exception of source files.


File Name

File Type


PIC UpDown Counter.ms10

Multisim 10 Circuit


PIC UpDown Counter.mcuws

MCU Module Workspace

..\PIC UpDown Counter\

C Project.mcuprj

MCU Module Project

..\PIC UpDown Counter\C Project


C-Code Source File

..\PIC UpDown Counter\C Project

Assembly Project.mcuprj

MCU Module Project

..\PIC UpDown Counter\Assembly Project

UpDown Counter.asm

Assembly Source File

..\PIC UpDown Counter\Assembly Project


The MCU project used in this tutorial uses a PIC16F84 from Microchip to demonstrate a simple up and down counter. Port A of the microcontroller is configured for input and connected to two switches. Port B is configured as output and connected to a 7-segment displays. The switches are used to turn the display on and off and change counting direction. The 7-segment display shows the current counter value (0-F). This MCU Module example consists of two identical projects. One build with assembly and one with C code.


Back to Top

3. Create A New MCU Project

  1. Open a new schematic in Multisim and place a PIC16F84 from the components library
  2. Step through the MCU Wizard
    1. Step 1: Define Workspace
      1. Enter workspace path: e.g. “c:\MCU Projects”
      2. Enter workspace name: e.g. “PIC UpDown Counter"
    2. Step 2: Define Project
      1. Project type: Standard
      2. Programming language: C
      3. Assembler/compiler tool: Hi-Tech PICC-Lite compiler
      4. Project Name: e.g. “C Code Project”
    3. Step 3: Define Source
      1. Source File Name: e.g. “main.c”
      2. Save your circuit: e.g. “PIC UpDown Counter.ms10”

Your Design Toolbox should look like this (select menu VIEW > Design Toolbox)

Back to Top

4. Enter Source Code And Additional Project

  1. Double click on the C source code file “main.c” to open the source code editor
    1. You can now enter your desired source code or copy and paste from other source files
  2. Use a text editor to open and copy the entire C code from “UpDown_Counter.c” hosted in the archive file
    1. Delete the default code (void main () call) and paste to “main.c”
    2.  Right click into the editor window and select “Show line number”
  3. Save and close the editor for “main.c”
  4. Open the MCU Code Manager
    1. Go to menu MCU > MCU PIC16F84 U1 > MCU Code Manager
    2. Right click on the workspace, project or source file name in the Design Toolbox and select “MCU Code Manager”
  5. Add a new assembler project to the current workspace
    1. Click “New MCU Project”
      1. Project Type: Standard
      2. Project Name: e.g. “Assembler Project"
    2. Set Active Project to: e.g. "Assembler Project"
    3. Add an existing source file to the new project
      1. Select the newly added project (e.g. “Assembler Project”)
      2. Click “Files…”
      3. Select the file “UpDown Counter.asm” from the archive
  6. Click OK to close the MCU Code Manager
  7. You are immediately taken to the source code editor for your new assembler source file
  8. Right click into the editor window and select “Show line number”
  9. Close the source code editor and save the entire circuit file


Back to Top

5. Place And Wire Peripheral Components

As a basic knowledge of NI Multisim is assumed, we do not go into detail how this circuits need to be completed.

Use the following components to complete the circuit as shown below. All components can be used with their default settings. If you like to view the default settings, right click on any component and select properties.

























J1, J2



MCU Module







R1, R2


Note: Instead of virtual wiring for VDD and bus vectors for the connection between Port B of the PIC16F84 and the Hex display, direct wiring can be used.


Back to Top

6. Simulate Your Circuit

  1. Set the Assembler Project as your active project
    1. An active project has a blue mark in the icon left to the project name
    2. Right click on a project name and select “Set Active MCU Project”
  2.   Start the simulation
    1. Confirm the dialog to build the source code
  3. The Hex display U2 should start counting up
  4. Use the switches J1 and J2 to test circuit behavior
    1. Click J1 to turn the display on and off
    2. Click J2 to change counting direction
    3. You can also assign keys from your keyboard to operate the switches (Value tab of components properties)
  5. Stop the simulation


Back to Top

7. Debug Your Source Code

  1. Open switch J2
  2. Open the source code editor
    1. Double click on “UpDown Counter.asm”
  3. Place a breakpoint in line 76
    1. Right click in editor window and select “Show Line Numbers”
    2. Right click in line 76 and select “Toggle Breakpoint”
  4. Close source code editor and save changes
  5. Start simulation
  6. Close switch
    1. Counter starts counting down
    2. Simulation will hit the breakpoint and switch to pause mode
    3. Debug view shows
  7. Select menu Window > Tile Horizontal
    1. Use scrollbars to adjust the circuit so you can see the display and the switches
  8. Click the Run/Resume simulation button (green triangle in toolbar)
    1. Simulation will do one complete cycle and pause at the breakpoint again
    2. The display will show the next number
  9. Open the Memory View
    1. Right click on the workspace, project or source file name and select “Memory View”
    2. Select menu MCU > MCU Windows.. > U1 Memory View > OK
    3. Adjust size of memory view if necessary
    4. Register and memory view will update every time the simulation is in pause mode
  10. Overwrite the memory space for the variable Counter (Counter EQU 0x1C)
    1. Expand the IRAM memory view
    2. Locate address 0x1C
    3. Double click to edit and enter new value (e.g. 0D)
    4. Click the Run/Resume simulation button
    5. Simulation will again pause at the breakpoint and display shows 0C
  11. Make yourself familiar with the debug tools (Step Into, Step Over, Step Out, …)
    1. Select from Simulation toolbar
    2. Select from menu MCU >
  12. Stop Simulation
  13. Remove all breakpoints
    1. Select menu MCU > Remove all breakpoints
  14. Select menu File > Save all


Back to Top

8. Switch Between Active Projects

A MCU Module workspace can have multiple projects that can consists of assembly or C code source files. If you like to repeat the steps above, set the project “C Code Project” as active MCU project.

  1. Set the Assembler Project as your active project
    1. An active project has a blue mark in the icon left to the project name
    2. Right click on a project name and select “Set Active MCU Project”
  2.   Repeat the above steps

Note: Source code line numbers, and memory addresses may vary.


Back to Top

9. Additional Resources


Back to Top

Customer Reviews
3 Reviews | Submit your review

  - Sep 22, 2011

can i have the program of that circuit

No Clock?  - Sep 21, 2010

I see the circuit designed without any kind of clock input or oscillator. Why?

How about speed of simulation  - May 21, 2008

Microcontrollers operates at even 400MHz. What is the possible speed of simulation in Multisim. Is it really possible to simulate the microcontroller?

Bookmark & Share





Rate this document

Answered Your Question?
Yes No