The example applications included in the MDK5 Software Pack for the redBlocks Simulator demonstrate how an embedded application written in C can easily be integrated with the redBlocks Simulator.
After having installed the “redBlocks Simulator” pack, select the Device “ARM” in the Pack Installer and switch to the “Examples” tab. You can now copy one of the example application projects and open it in the uVision IDE:
There is one example application with and another one without RTX support. Both examples demonstrate how to use the C Target Simulation API. However, you can certainly use the C++ Target Simulation API instead (like shown in this tutorial).
The example application consists of a push button and a lamp that can be switched between the states flashing, on and off by pressing the push button.
You should already be able to compile the example application within the Keil uVision IDE. However, in order to run it, you need to simulate the hardware (i.e. the push button and the lamp). This is what the redBlocks Simulator is responsible for. Therefore, you need to download the redBlocks Eval Package that includes the redBlocks Simulator. After that, you can open the sample simulation project "HelloWorld.rbp" in the redBlocks Simulator (it is included in both example applications in the subdirectory "sim") and see a simple button and an LED symbol on the screen:
Now you are ready to run the example application in the virtualized environment:
- Enable the UVSOCK interface and set the port number to 4823 in the uVision IDE (menu "Edit"->"Configuration", tab "Other"). Make sure that there is no other service using this port on your computer and check whether there is only one uVision instance running, otherwise the connection between the uVision IDE and the redBlocks Simulator cannot be established.
In case you experience any problems with the connection between the redBlocks Simulator and the uVision IDE, close all instances of the uVision IDE and restart it with the desired project.
- Start the simulation in the redBlocks Simulator (menu "Simulation"->"Start Simulation").
- Now start the debugging session in the uVision IDE and run the program.
The symbol representing the lamp in the redBlocks Simulator should now be flashing. By pressing the push button you can change the state. Feel free to experiment, e.g. set a breakpoint in the program's source code in the uVision IDE and watch the redBlocks Simulator pause when the breakpoint is hit and proceed its operation when the program execution is continued in the uVision Debugger.
In order to learn more about the anatomy of an application that runs in the redBlocks Simulator's SiL environment and how to operate the redBlocks Simulator, refer to the Platform Abstraction concept and the online tutorials. Visit this tutorial in order to learn, how to set up a project and the graphical representation of an embedded device from scratch. There is also a dedicated tutorial that explains the Interaction of the redBlocks Simulator with the uVision IDE.
In order to implement / integrate your own applications with the redBlocks Simulator, refer to the description of the C and C++ Target Simulation API. It can be found in the redBlocks Simulator's documentation (see Programming Interfaces -> Target Simulation Library) that can be accessed from the menu "Help" in the redBlocks Simulator. In case you have any questions feel free to contact us. We will be happy to assist.