Reviewing the Invert Sample Source Code

This simple application inverts the value of a single input signal and writes the inverted value to a single output signal.  As you work on your own, your system will become all the files that comprise the application layer of your system.

In our Invert example, the application source code is located under My Documents in this subdirectory:


You can view the source code in Visual Studio's Solution Explorer window.

The source file Main.c contains the following code:

#include "Types.h"

#include "Main.h"


uint8 InVal;

uint8 OutVal;


void Init(void)


  OutVal = 1;



void Task_5ms(void)


  if (InVal == 0)

      OutVal = 1;


      OutVal = 0;


Things to note about this file:

It has one input value (InVal).

It has one output value (OutVal).

It has two functions or tasks (Init and Task_5ms).

Reviewing the MxVMC Interface Source Code

The Test Harness code connects the MxVDev tool to the application source code. Locate the file AppIF.c in the MxSuiteSamples\InvertSample\SUT\MxVHarness folder. Double-click to view it in Visual Studio.  This is a very basic harness file, but it is a good example of what a harness looks like.

Things to note about this file:

Types.h and Main.h are included.  These files are part of the Invert application code.

The TaskDefs table has one entry called Task_5ms. This entry describes the Task_5ms function to the MxVDev user interface.

The PortDefs table has two entries: one input signal, and one output signal. These entries describe the two variables InVal and OutVal to the MxVDev user interface.

All future MxVMC interfaces can be created using this very simple AppIF.c file as a starting point.

Building the System Under Test

1.Rebuild the project or solution using Visual Studio. Be sure to perform a full rebuild to ensure you can compile an entire project. It is installed pre-compiled, so rebuild is necessary only for full-development cycle testing.

a.To prevent file-in-use errors, be sure MxVDev is closed before performing a build. (If you want to keep MxVDev open, disconnect the Harness.)

b.Delete the old MxVTarget.pdb file from the SUT subfolder of the project folder.

c.If the build is unsuccessful, use the Set as Current Version command as described in Visual Studio and MxVDev.

2.If you are finished debugging the SUT code, you can close Visual Studio.

The next step is Creating a TestCase.


Related Topic:

Debugging SUT Applications Using Mx VDev and Visual C++