Table of Contents

1. Introduction
2. Compiling and executing the example
3. Debugging and LPMs

1. Introduction

This chapter presents the serial port example. Like the previous examples, this one is also written for the WSN430 hardware platform and it demonstrates communication through the serial port in WSim. It is a simple application that produces an echo for every character sent to its serial port 1.

2. Compiling and executing the example

To compile the example, follow the same instructions as before. For users of the Worldsens Live CD, the folder containing this example is /opt/worldsens/examples/wsn430-serial. For other, go to $WSIM_FOLDER/examples/wsn430/wsn430-serial.

To execute the example users will have to follow the procedure below:

  1. Launch an instance of the Worldsens WConsole application, as follows:

    [wsn430-serial]$ wconsole

    You should see this:

    Snapshot of the launching of the serial console

    Figure V.1. Snapshot of the launching of the serial console

  2. Launch the simulator and connect it to the previously launched WConsole instance, using the following command (expected output is included):

    [wsn430-timer]$ wsim-wsn430 --serial1_io=/dev/pts/3 wsn430-serial.elf
    WSim 0.82cvs, copyright 2005, 2006, 2007 Worldsens

    Once you attach the serial console to the simulated platform's serial port 1, the application will let you switch between its two modes by typing "Z". The two available modes are:

    • IRQ+LPM0: in this mode the program starts by checking if a character is available on the serial port; if no character is available, it goes into a Low Power Mode (see the TI MSP430 User Guide), LPM0 to be precise; all subsequent characters are processed in interrupt routines.
    • polling: in this mode, the program is constantly checking if the user has entered any new character on the serial port.

    The top half of the user interface window presents the simulation output with grayed letters and bottom half is the local keyboard echo for the host machine. In both modes, all the text you type will be echoed by the application in the upper part of the serial console.

    Snapshot of the execution of the serial example

    Figure V.2. Snapshot of the execution of the serial example

3. Debugging and LPMs

As explained above, the IRQ+LPM0 mode consists of a sequence of LPM0 periods and executions of interrupt routines. For this reason, bla bla bla.