The Javelin
Stamp provides an interesting example of a hardware Java platform.
Of the hardware processors discussed above,
it offers the most restricted set of bytecode instructions and the
most limited set of classes. It does not reach even the level of
the CLDC framework and so presents an even
more limited environment. However, it is low cost, fairly simple
and straightforward to use, and for many microcontroller applications
its capabilities will suffice.
Parallax
intended the Javelin Stamp to be as easy to use as its popular Basic
Stamp modules. You can use the development card, which comes
with a small breadboard (see figure),
for experimentation and tests. To get to know the system you can
place LEDs, buttons, and other circuits on the breadboard and connect
them to the Javelin module’s I/O pins (16 pins) that are accessible
to the Java programs.
The Javelin
Stamp’s JVM differs in several ways from the one that came with
your SDK. For example, there is no multitasking or multithreading.
Instead you can use a timer object to allocate times for tasks to
run. In addition, six commonly needed functions are provided by
virtual peripherals (VP)
that come built into the Javelin’s firmware. The VPs include a timer,
UART for serial communications, PWM (Pulse Width Modulation) for
pulse train generation, DAC and ADCs. You can install up to 6 VPs
at a time and they run in the background, using a minimal amount
of processing time and resources. (Each VP requires a certain number
of the 16 available I/O pins.)
The Javelin
processor offers no garbage collection so once you create objects
they exist until the module is reset. This places tight restrictions
on the number and size of objects that you can create to avoid filling
up the available memory. However, the absence of a GC means that
the system can respond in real-time without the uncertainty
as to when a GC might interrupt it and for how long a GC might run.
Other limitations include a 16-bit maximum data
width, even for the int type (no long type). The standard packages only allow
for integers, though, a 16-bit FP package from an independent source
is now available (ref). You can create 1D arrays but not 2D. A number
of core Java packages are either missing (no java.net for example) or truncated
Segment of a screen capture of the Javelin Stamp
IDE in action.
An IDE (see figure above) provided for the Javelin
uses a serial port on the module to load a program and to start
it. (This port differs from the ones created with the UART VP and
the I/O pins.) Once the program is loaded into the EEPROM, the serial
port can be disconnected and the module will run independently.
(A reset pin will restart a program when brought to ground and then
released.) From the IDE you can edit, compile, download, and run
a program. It includes a debugger with breakpoints for stepping
through a program's execution. While the serial line is connected,
the System.out.print() methods will send messages for output in
a IDE window.
Sixteen of the 24 pins on the module are accessible from the Java
program for input or output. The API offers many different methods
that use the I/O pins. There are methods, for example, simply to
set a pin to 5V or to reading its current input value, methods to
send out pulse trains, to read an analog value, and to act as one
of the transmit or receive lines for a serial UART communications
port.
In the following section we illustrate programming of the Javelin
with a demo program that reads
the temperature values provided by a chip on the breadboard. The
Javelin in turn sends the values over a serial line to a PC running
the programs we developed in Chapter
23.
References and Web Resources
Latest update: Dec. 14, 2004
|