Difference between revisions of "MSPSim"
(→Step by step execution) |
m (→Step by step execution) |
||
Line 66: | Line 66: | ||
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. | 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. | ||
=== Step by step execution === | === Step by step execution === | ||
− | Another useful | + | Another useful feature of MSPSim is the step by step execution. It can be done by clicking the button ''Stop'' of the main window of MSPSim, the window called ''MSPSim monitor''. Then the program can be executed step by step with the button ''Single Step''. The mode debug can be enabled with the button ''Debug On'', this mode display more information of each step execution in the command line window. An example of such output is: |
49aa: 3f f0 10 00 AND.W #$0010, R15 R15=0001 R0=49aa SR=--Z- SP=38fc; as = 3 sMem:0000 | 49aa: 3f f0 10 00 AND.W #$0010, R15 R15=0001 R0=49aa SR=--Z- SP=38fc; as = 3 sMem:0000 | ||
49ae: 07 24 JEQ $000e SR=--Z- | 49ae: 07 24 JEQ $000e SR=--Z- |
Revision as of 21:22, 13 December 2009
MSPSim is a Java-based simulator of the MSP430 microcontroller.
Contents
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 number of cycles elapsed in 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.
Step by step execution
Another useful feature of MSPSim is the step by step execution. It can be done by clicking the button Stop of the main window of MSPSim, the window called MSPSim monitor. Then the program can be executed step by step with the button Single Step. The mode debug can be enabled with the button Debug On, this mode display more information of each step execution in the command line window. An example of such output is:
49aa: 3f f0 10 00 AND.W #$0010, R15 R15=0001 R0=49aa SR=--Z- SP=38fc; as = 3 sMem:0000 49ae: 07 24 JEQ $000e SR=--Z- 49be: 5f 42 04 00 MOV.B &ME1, R15 R15=0000 R2=0002 SR=--Z- SP=38fc; as = 1 sMem:0000 49c2: 7f f0 c0 ff AND.B #$ffc0, R15 R15=0000 R0=49c2 SR=--Z- SP=38fc; as = 3 sMem:0000 49c6: 05 24 JEQ $000a SR=--Z-
The step by step execution can also be executed in command line with the command step. This command accepts an integer as parameter which is the number of instructions to execute. An example of this command is :
MSPSim>step 10 49d2: 5f 42 05 00 MOV.B &ME2, R15 R15=0000 R2=0002 SR=--Z- SP=38fc; as = 1 sMem:0000 49d6: 7f f0 30 00 AND.B #$0030, R15 R15=0000 R0=49d6 SR=--Z- SP=38fc; as = 3 sMem:0000 49da: 05 24 JEQ $000a SR=--Z- 49e6: 5f 42 70 00 MOV.B &UCTL_0, R15 R15=0000 R2=0002 SR=--Z- SP=38fc; as = 1 sMem:0000 49ea: 5f f3 AND.B #1, R15 R15=0000 R3=0000 SR=--Z- SP=38fc; as = 1 sMem:0000 49ec: 14 24 JEQ $0028 SR=--Z- 4a16: 1f 42 a0 01 MOV.W &ADC12CTL0, R15 R15=0000 R2=0002 SR=--Z- SP=38fc; as = 1 sMem:0000 4a1a: 3f f0 10 00 AND.W #$0010, R15 R15=0000 R0=4a1a SR=--Z- SP=38fc; as = 3 sMem:0000 4a1e: 18 24 JEQ $0030 SR=--Z- 4a50: 4f 4e MOV.B R14, R15 R15=0000 R14=0004 SR=--Z- SP=38fc; as = 0 sMem:0000 CPU stepped to: $4a52 in 21 cycles (6252752)
At the end of this command, the number of cycle elapsed is displayed.