Archived: Using the Cycle-Accurate ARM Microcontroller Simulator

Publish Date: Mar 21, 2018 | 5 Ratings | 4.80 out of 5 | Print | Submit your review


This document has been archived and is no longer updated by National Instruments.

Table of Contents

  1. Using the Cycle-Accurate ARM Microcontroller Simulator
  2. Running an Application on the Simulator
  3. Changing the Analog Input Value Manually
  4. Automating Stimulus and Response
  5. Validating the Complete Design
  6. Simulating the Complete Design with LabVIEW and Multisim

1. Using the Cycle-Accurate ARM Microcontroller Simulator

The LabVIEW Embedded Module for ARM Microcontrollers includes support for the RealView µVision ARM simulator, which provides cycle accurate timing and logic simulation.  In addition, the simulator supports many of the on-chip peripherals so that you can provide controlled stimulus and response for debugging and testing your application.   With this capability, you can develop and test large portions of the application before the hardware design is complete.

This tutorial will discuss several ways to take advantage of this feature to help you develop higher quality code more quickly, including how to to co-simulate peripheral analog circuitry with the NI Multisim SPICE simulation environment.


Back to Top

2. Running an Application on the Simulator

  1. To run an application on the LabVIEW simulator, you must first create a LabVIEW Project. 
    • Select ARM Project from the dropdown menu and press Go to start the ARM project wizard.


    • Click Next to create a New VI.
    • Choose the processor that you wish to simulate.  In this tutorial, we will simulate the MCB2300 evaluation board. Click Next.


    • Select the Run on Simulator option and click Finish.  LabVIEW will generate a project file and two VIs.  You will be prompted to save each of these files.


  1. Now build your application.  In this case, we have developed a simple VI that reads an analog input and checks it against a threshold.  If that threshold is exceeded, LED0 is lit.  
    • Right click the MCB2300 target in the LabVIEW project and choose New>>Elemental I/O to add the I/O nodes to your project tree.


    • Add Analog Input >> AIO and Digital Output >> LED0 to the project.
    • Switch to the block diagram of the open VI by choosing Window>>Show Block Diagram.
    • Drag and drop the Elemental I/O nodes from the project to the block diagram.
    • Complete the block diagram and front panel as shown.  Notice that the value returned from the A/D is the integer representation of the 10-bit A/D value, so a value of 512 is equal to approximately 1.66 V.


  1. Click the Run arrow to generate and compile the C code and run the application on the simulator.  The processor status window will reflect the status of the simulator.


Back to Top

3. Changing the Analog Input Value Manually

Now that the application in running, you can feed an analog value to the simulated A/D converter to test the logic of your code.  You can do this one of two ways, manual or automated.  To manually change the value, you will access the uVision IDE directly.

  1. To launch µVision, right click the MCB2300 target in the project tree and choose Show Keil uVision.


  1. In the Keil uVision IDE, choose Peripherals>>A/D Converter>>A/D Converter 0.  This will launch the peripheral simulator interface.
  2. In the Analog Inputs section, change the value of AD00 to 2.0.   This will change the value that the simulated A/D converter returns in the LabVIEW software.  This value is in volts, and the 10-bit A/D has a valid input range of 0-3.3V, so 2V will convert to an integer value of 620.  This can be calculated using the following formula.

  1. The output value can be viewed using the LabVIEW indicator.  In addition, you can view the value of the digital ports by choosing Peripherals>>GPIO Fast Interface>>Port 2.  The LED is connected to port 2 line 0.


Back to Top

4. Automating Stimulus and Response

An alternative to the manual method outlined above is using a separate VI to send and receive data to and from the simulated peripherals.  The LabVIEW Embedded Module for ARM Microcontrollers installs an additional palette to provide a simple way to develop complex and automated stimulus response tests for your simulated embedded system. 

  1. Open the Simulated IO VI that was generated by the wizard.  It can be found under My Computer in the LabVIEW project.
  2. When you open the block diagram, you will notice that there is already template code for communicating with the simulator. 


    • The code configures the time step of the simulation, opens a connection to the running simulator, and stops the simulator so that LabVIEW can send data.
    • In the middle frame of the sequence structure, you can add your code to perform stimulus response.
    • After the data is updated, the simulator is allowed to begin again.  Once the simulation is complete, the connection is terminated.
  1. In this tutorial, we will send a sequence of inputs to the simulator that are stored in a LVM (LabVIEW measurement file).


    • Right click the while loop and replace it with a For Loop
    • Using the VIs in the ARM>>ARM Simulation Signal Generation palette, we can write and read the simulation data one point at a time.
    • The data is collected and displayed on a waveform chart.
  1. After running the simulation, we can compare the results to the expected behavior.  In this screenshot, we can see that the Boolean output goes high whenever the input rises above 1.66V.


Back to Top

5. Validating the Complete Design

An embedded ARM Microcontroller is one element of a larger design. The complete design also consists of analog and digital components that are external to the embedded device. For example, signals input to the microcontroller often require some form of signal conditioning, such as filtering or amplification in order to make it an appropriate stimulus. These types of external devices influence the behavior of an embedded device, and therefore simulation of the ARM microcontroller by itself may not provide a complete understanding of the system behavior.

By leveraging the simulation environment of the LabVIEW Embedded Module for ARM Microcontrollers, you can integrate to the analog and digital simulation of NI Multisim. By integrating the simulation between these two stages of the design, the influence of external signal conditioning can be better analyzed. This simulation across multiple environments is termed co-simulation and can help to eliminate common errors, and more accurately debug and test application code before it is physically implemented.

Multisim is an easy-to-use, intuitive and powerful mixed-mode simulation environment for circuit design. Through the  integration to the LabVIEW test environment, engineers have an unique platform to coordinate both PCB design and validation. All simulation measurements in the Multisim circuit design environment, and LabVIEW, can be saved to a LabVIEW Measurement (LVM) file format.  The native language of communication between these NI products is LVM, and therefore we can easily transfer the output of one simulated module to the other.


Back to Top

6. Simulating the Complete Design with LabVIEW and Multisim

We can begin validating the behavior of our complete by continuing our previous LabVIEW example.

A common design requirement for interfacing a signal to an ARM microcontroller is signal conditioning. For example, something as simple as a voltage divider is required to step down a voltage before it can become a stimulus for an ARM processor.

  1. To interface an analog signal to the microcontroller, you must first design a circuit in Multisim.
    • Open NI Multisim (Start > All Programs > National Instruments > Circuit Design Suite 10.0 > Multisim)
    • Design the circuit pictured below (you may also open the attached circuit file named simple_voltage_divider.ms10)

    • Double-click on the function generator (XFG1) and set Frequency to 10 kHz, and Amplitude to 5 Vp.
    • Click on the simulate button (highlighted in red in the image below).

    • Click on the simulate button (highlighted in red in the image below).
    • Double-click on the oscilloscope (XSC2) and view the simulated output of the voltage divider.
    • Click on the Save button in the oscilloscope (pictured below). 
    • Change the Save as Type drop-down box to Text-Based Measurement file (*.lvm) and save the file as multisim_output.LVM.
    • Click OK in the Data resampling  settings dialog box.

  1. We can now bring the MultisimOutput.lvm simulated response into the LabVIEW simulation environment to interface to the ARM Microcontroller.
    • Before simulating make the following changes to the previous LabVIEW VI.
    • The new VI algorithm saves the output of the ARM microcontroller to an LVM file.
    • Double-click on the Read from Measurement File Express VI.
    • In the File-Name dialog, browse to the MultisimOutput.lvm file previously saved.
    • Click on the Run button, to compile and execute the code.

After running the simulation, we can compare the results to the expected behavior.  In this screenshot, we can see that the Boolean output goes high once more whenever the input rises above 1.66V.

Using this integrated platform there is a flexible strategy to validate the complete embedded design.

The saved simulated data from the VI (saved to a file named LabVIEWOutput.lvm) can now to be used again within the Multisim environment. The simulated data can be saved, or alternatively used as a stimulus within Multisim. This iterative looping between analog circuitry and the embedded processor can allow easy feedback of simulated data to improve the overall analysis of the system.

Back to Top

Bookmark & Share


Rate this document

Answered Your Question?
Yes No