Table of Contents

1. Introduction
2. Compiling and executing the example
3. Converting and interpreting the traces

1. Introduction

This chapter presents the timers example. This application written for the WSN430 hardware platform aims at demonstrating WSim's capability to simulate interrupts. We will also discuss setting breakpoints in an application using LPMs (Low Power Modes).

2. Compiling and executing the example

If you are using the Worldsens Live CD, go to /opt/worldsens/examples/wsn430-timer. If not, go to $WSIM_FOLDER/examples/wsn430/wsn430-timer and type:

[wsn430-timer]$ make

You should see:

msp430-gcc -mmcu=msp430x1611 -O2 -Wall -I../wsn430-leds -I../wsn430-clock -I../wsn430-serial -g   -c -o main.o main.c
msp430-gcc -c -mmcu=msp430x1611 -O2 -Wall -I../wsn430-leds -I../wsn430-clock -I../wsn430-serial -g ../wsn430-clock/clock.c
msp430-gcc -c -mmcu=msp430x1611 -O2 -Wall -I../wsn430-leds -I../wsn430-clock -I../wsn430-serial -g ../wsn430-serial/uart1.c
msp430-gcc -mmcu=msp430x1611 -O2 -Wall -I../wsn430-leds -I../wsn430-clock -I../wsn430-serial -g   -c -o timer.o timer.c
msp430-gcc -mmcu=msp430x1611 -o wsn430-timer.elf main.o clock.o uart1.o timer.o
msp430-objcopy -O ihex wsn430-timer.elf wsn430-timer.a43
msp430-objdump -dSt wsn430-timer.elf >wsn430-timer.lst

If you are not using the Worldsens Live CD and you see an error, make sure all the tools are in your $PATH.

Once the example is compiled, you can execute it using WSim with the same options presented in the previous example, i.e.:

  • ui: to show the user interface (i.e. the LEDs blinking).
  • trace: write simulator traces in a file (wsim.trc).
  • mode: WSim mode (time, insn or gdb); if this is not specified, WSim will run forever.
  • modearg: if mode is time or insn, then this option will specify the simulation time in nanoseconds or number of instructions.

The command to type is therefore the following (expected output is included below):

[wsn430-timer]$ wsim-wsn430 --ui --trace --mode=time --modearg=100000000000 wsn430-timer.elf
WSim 0.82cvs, copyright 2005, 2006, 2007 Worldsens
[Note]The mode option

As explained above, when the mode option is not used, simulation time is unlimited. It is important to note that, in this case, trace data are kept in a buffer of relatively large size (approx. 4 MB). Therefore, should the user interrupt the simulation (killall -USR1 wsim-wsn430), they should expect the trace files to be empty.

Snapshot of the execution of the timer example

Figure IV.1. Snapshot of the execution of the timer example

3. Converting and interpreting the traces

After having converted the trace file as explained in the previous example, you will again obtain EPS files for each type of data:,,,,,,,,,,,, However, this time, besides from LED files, another interesting file to analyse is the interrupt file,, which presents harware interrupts issued during the execution of the program by the simulator. This file is included below, as well as LED trace files:

Interruptions for the timer example

Figure IV.2. Interruptions for the timer example