MSPSim
MSPSim is a Java-based simulator of the MSP430 microcontroller.
Installation
After dowloading the last version of MSPSIM, it can be install by entering the command:
make
in the MSPSim folder. A Jar package of MSPSim can be created with the command:
make jar
Then a mspsim.jar is created in the directory. For simplicity, you may want to create an alias to MSPSim:
alias mspsim="java -jar PATH_TO_MSPSIM/mspsim.jar"
After that, MSPSim can be lauched with the command mspsim
Usage
Blink application
We show in this section how to use MSPSIm on the Blink application. First we need to compile the application for the TelosB mote which uses the MSP430 microcontroller with the command:
make telosb
Since MSPSim can open ELF file we have to rename the program file:
mv build/telosb/main.exe build/telosb/main.elf
Then we can run MSPSim:
mspsim builb/telosb/main.elf
Five windows of MSPSim should open, in one of then you should see a picture of the mote with the LED blinking at different frequency. In the terminal you should obtain a MSPSim prompt:
Flash got reset! MSPSim>Autoloading script: PATH_TO_MSPSIM/scripts/autorun.sc ----------------------------------------------- MSPSim 0.97 starting firmware: main.elf ----------------------------------------------- MSPSim>
You can enter the command help inside this prompt to have a list of the available commands.
Profiling
The MSPSim command profile can be useful to see the energy consumed by each function of the program. An example of output of this command is:
MSPSim>profile ************************* Profile Data ************************************** Function Average Calls Tot.Cycles McuSleepC$getPowerState 55 4593 252615 Msp430ClockP$busyCalibrateDco 26110 1 26110 MotePlatformC$Init$init 10607 1 10607 Msp430TimerP$1$Event$fired 14 35 490 Msp430ClockP$set_dco_calib 23 13 299 MotePlatformC$TOSH_FLASH_M25P_DP 259 1 259 MotePlatformC$TOSH_FLASH_M25P_DP_bit 21 8 170 SchedulerBasicP$Scheduler$runNextTask 17 2 34 __nesc_atomic_start 14 2 28 __nesc_atomic_end 8 1 8 ********** Profile IRQ ************************** Vector Average Calls Tot.Cycles 00 0 0 0 01 0 0 0 02 0 0 0 03 0 0 0 04 0 0 0 05 53 4557 241521 06 0 0 0 07 0 0 0 08 0 0 0 09 0 0 0 10 0 0 0 11 0 0 0 12 58 35 2030 13 0 0 0 14 0 0 0 15 0 0 0
The first profile shows for each function, the average number of cycles spent into, the number of calls to this function and the total number of cycles spent. The second profile shows the interrupt requests of the program.