Code Examples

Common tasks, examples of proper hardware usage, WISP testing code, etc.

WISP 4.1DL Functional Example Code

This code is meant to be used on the WISP in wirelessly powered operation to accomplish some task.

Code examples require WISP 4.1 DL pin definitions: pinDefWISP4.1DL.h

a. Extremely Simple Sleep Code : Stop the watchdog, set the pin directions correctly, and go to LPM4 sleep mode.


Theory of Operation:

This code sets all pin directions, thus preventing any pin from being floating. This reduces quiescent current draw significantly. Also, the microcontroller is placed in the lowest power sleep mode to keep current draw minimized.

b. Blinky: Flash LED Using Vout Polling : After a set interval counted by the 32 kHz ACLK while in LPM3, we wake and sample Vout. If we have enough voltage, we blink the LED, otherwise, go back to polling. Also, we don't bother sampling the voltage if the supervisor is low.


WISP 4.1DL Hardware Testing Code

The following code was used to test the functionality of the WISP 4.1DL hardware. Most code requires the debugger to be used as a power supply to run the code (in other words, it may not run when the WISP used in its normal mode of operation). It may, however, provide a good starting point for using the hardware.

Owners: - ripras, - yeagerd, - pollyp

a. Voltage Sensing + ADC Test: Fast sample of voltage sensor to detect current voltage. Setup: Hook Vout line on WISP to Power Supply. Formula to convert ADC value to Voltage = (ADC/1024)*Vsupply*3. Requires debugger power.


b. ACLK + LED Test: After a set interval counted by the 32 kHz ACLK, the LED on the WISP is toggled on (or off). Requires debugger power.


c. Accelerometer Test: The accelerometer takes a long time to settle out (roughly 15 ms), but it also draws a lot of current (about 200 uA). So, how small of a settling time can we get away with? This code measures settling time and sampling noise associated with each sampling time.

Requires debugger power.


Accelerometer Testing.xls

(Also requires WISP 4.1 DL pin definitions - see Hardware Page)

d. EEPROM Test: Exercise the EEPROM by reading and writing data. See EEPROM.

Code from UMass

The following code was originally developed by students at UMass Amherst and performs a number of tasks that we have found to be common. They are generally simple and similar examples can be found on TI's website, but we have tested these implementations on the WISP and put them into simple functions to avoid code duplication. This code was written for WISP revision 1.0 and the pin definitions are not the same!

Owners: - ssclark, - ransford

Modular exponentiation: A semi-intelligent modular exponentiation implementation that should work on any WISP. This code does not have custom bignum support, so your result will be invalid if you overflow a long long.


RC5: A lightly modified implementation of RC5 from TinySec that will run on the WISP 1.0. Probably only requires a change of the MSP-specific header file to work on newer WISPs.

gpio_xmit : Outputs an integer on a GPIO pin using Manchester encoding.

gpio_xmit.h, gpio_xmit.c

flash_ops : Enables flash writes and performs segment erases.

flash_ops.h, flash_ops.c

ransford_adc : Takes ADC samples for self-measurement of voltage levels.

ransford-adc.h, ransford-adc.c

ta_sleep : Has functions to sleep for either a number of microseconds or milliseconds.

ta_sleep.h, ta_sleep.c

Code from Wireless Sensing Lab, Univ. of WA

I2C Interface for BMP085 Pressure Sensor Sampling Firmware

Texas Instruments Sample Code Links

Java-based LLRP Reader Application from Network Security Lab, Univ. of WA

Thanks to Tony Wu - mdzz in the UW Network Security Lab for contributing this WISP demo application written in Java!

This application provides the “Read” and “BlockWrite” commands. The LLRP Java Toolkit (LTK Java) is required, see for a download.

Please note that the current WISP 4.1 firmware revision may not support Read and BlockWrite.