Difference between revisions of "MSPSim"
m (→Profiling) |
m (→See also) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
== Installation == | == Installation == | ||
− | After dowloading the last version of MSPSIM, it can be | + | After dowloading the last version of MSPSIM from [http://sourceforge.net/projects/mspsim/files/mspsim/0.97/mspsim-source-2009-04-30.zip/download here], it can be installed by entering the command: |
make | make | ||
in the MSPSim folder. A Jar package of MSPSim can be created with the command: | in the MSPSim folder. A Jar package of MSPSim can be created with the command: | ||
Line 12: | Line 12: | ||
== Usage == | == Usage == | ||
+ | === Help === | ||
+ | You can enter the command ''help'' inside the MSPSim prompt to have a list of the available commands. Some help can be display for each command with the ''help'' command by entering: | ||
+ | help [command] | ||
+ | where ''[command]'' is the command name. | ||
=== Blink application === | === 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: | 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: | ||
Line 27: | Line 31: | ||
----------------------------------------------- | ----------------------------------------------- | ||
MSPSim> | MSPSim> | ||
− | |||
− | |||
=== Profiling === | === Profiling === | ||
Line 65: | Line 67: | ||
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 === | ||
+ | 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. | ||
+ | === Variables and function calls=== | ||
+ | MSPSim allows to watch the variable values evolution during the program execution. To illustrate that we used the RadioCountToLeds application available in the TinyOS 2.1 tree. Once MSPSim is launch, we first stop and reset the simulation: | ||
+ | MSPSim>stop | ||
+ | CPU stopped at: $4db2 | ||
+ | MSPSim>reset | ||
+ | Then we list the variables of the module and there corresponding address in memory. | ||
+ | MSPSim>symbol RadioCountToLedsC | ||
+ | RadioCountToLedsC$counter at $1108 (1c 00) | ||
+ | RadioCountToLedsC$locked at $1139 (00 00) | ||
+ | RadioCountToLedsC$packet at $113c (0f 41) | ||
+ | RadioCountToLedsC$Receive$receive at $6b14 (0b 12) | ||
+ | |||
+ | The symbol command take any expression as parameter. For example: | ||
+ | MSPSim>symbol counter | ||
+ | RadioCountToLedsC$counter at $1108 (29 00) | ||
+ | The value in parentheses is the values of the variable. Then we can add a watch to the counter value: | ||
+ | |||
+ | MSPSim>watch RadioCountToLedsC$counter | ||
+ | Watch set at $1108 | ||
+ | |||
+ | and run the simulation: | ||
+ | |||
+ | MSPSim>start | ||
+ | *** Write from 401a: RadioCountToLedsC$counter = 0 | ||
+ | MSPSim>Timer B Assigning Port: 4 pin: 1 for capture | ||
+ | Setting timer capture for pin: 1 | ||
+ | *** Read from 52cc: RadioCountToLedsC$counter = 0 | ||
+ | *** Write from 52ce: RadioCountToLedsC$counter = 1 | ||
+ | *** Read from 52ea: RadioCountToLedsC$counter = 1 | ||
+ | *** Read from 52cc: RadioCountToLedsC$counter = 1 | ||
+ | *** Write from 52ce: RadioCountToLedsC$counter = 2 | ||
+ | *** Read from 52ea: RadioCountToLedsC$counter = 2 | ||
+ | *** Read from 52cc: RadioCountToLedsC$counter = 2 | ||
+ | *** Write from 52ce: RadioCountToLedsC$counter = 3 | ||
+ | *** Read from 52ea: RadioCountToLedsC$counter = 3 | ||
+ | *** Read from 52cc: RadioCountToLedsC$counter = 3 | ||
+ | |||
+ | We can see the evolution of the value during the simulation. The simulation can be stopped by entering the command ''stop'' and pressing the enter key at any time. Simultaneous variable can be watched during the simulation by adding more watch. The same method can be enployed to monitor function calls. | ||
== See also == | == See also == | ||
− | *[[Avrora]] | + | *[[Avrora]], a simulator for AVR microcontrollers. |
+ | *[[WSim]], another simulator for MSP430. | ||
+ | |||
== External links == | == External links == | ||
*[http://sourceforge.net/projects/mspsim Sourceforge page] | *[http://sourceforge.net/projects/mspsim Sourceforge page] | ||
*[http://www.sics.se/%7Eadam/eriksson07mspsim.pdf Poster abstract on MSPSim] | *[http://www.sics.se/%7Eadam/eriksson07mspsim.pdf Poster abstract on MSPSim] | ||
[[Category:Software]] | [[Category:Software]] |
Latest revision as of 04:12, 2 March 2010
MSPSim is a Java-based simulator of the MSP430 microcontroller.
Contents
Installation
After dowloading the last version of MSPSIM from here, it can be installed 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
Help
You can enter the command help inside the MSPSim prompt to have a list of the available commands. Some help can be display for each command with the help command by entering:
help [command]
where [command] is the command name.
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>
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.
Variables and function calls
MSPSim allows to watch the variable values evolution during the program execution. To illustrate that we used the RadioCountToLeds application available in the TinyOS 2.1 tree. Once MSPSim is launch, we first stop and reset the simulation:
MSPSim>stop CPU stopped at: $4db2 MSPSim>reset
Then we list the variables of the module and there corresponding address in memory.
MSPSim>symbol RadioCountToLedsC RadioCountToLedsC$counter at $1108 (1c 00) RadioCountToLedsC$locked at $1139 (00 00) RadioCountToLedsC$packet at $113c (0f 41) RadioCountToLedsC$Receive$receive at $6b14 (0b 12)
The symbol command take any expression as parameter. For example:
MSPSim>symbol counter RadioCountToLedsC$counter at $1108 (29 00)
The value in parentheses is the values of the variable. Then we can add a watch to the counter value:
MSPSim>watch RadioCountToLedsC$counter Watch set at $1108
and run the simulation:
MSPSim>start *** Write from 401a: RadioCountToLedsC$counter = 0 MSPSim>Timer B Assigning Port: 4 pin: 1 for capture Setting timer capture for pin: 1 *** Read from 52cc: RadioCountToLedsC$counter = 0 *** Write from 52ce: RadioCountToLedsC$counter = 1 *** Read from 52ea: RadioCountToLedsC$counter = 1 *** Read from 52cc: RadioCountToLedsC$counter = 1 *** Write from 52ce: RadioCountToLedsC$counter = 2 *** Read from 52ea: RadioCountToLedsC$counter = 2 *** Read from 52cc: RadioCountToLedsC$counter = 2 *** Write from 52ce: RadioCountToLedsC$counter = 3 *** Read from 52ea: RadioCountToLedsC$counter = 3 *** Read from 52cc: RadioCountToLedsC$counter = 3
We can see the evolution of the value during the simulation. The simulation can be stopped by entering the command stop and pressing the enter key at any time. Simultaneous variable can be watched during the simulation by adding more watch. The same method can be enployed to monitor function calls.