© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Page 25 of 52
Memory Map
Your PBASIC program has read-only access to 48 bytes of the TSL1401R driver’s internal memory. This
memory is used for storing binary pixel values, image acquisition stats, and the results of various image
processing functions. It is laid out as follows:
Name
Addr
Description
PIXELS
$00
to
$1F
Binary pixel data. Pixels are packed LSB first. Since there are only 255 pixels,
the last pixel (bit 7 of location
$1F
) is always
0
.
RESULTS
$20
to
$24
Beginning of the results buffer. The internal result pointer is set here after a
reset and after state changes between immediate and buffered modes.
$25
to
$2F
Beginning of the command buffer (11 bytes) and continuation of the results
buffer.
The named constants shown above are predefined in the code template near the end of this chapter. The
32-byte
PIXELS
area will always contain the results of the latest binary scan. Following that is the 16-
byte
RESULTS
buffer. Immediately after an image is acquired, five bytes of the results buffer will contain
statistics from the acquisition. These are discussed in detail in the image acquisition section. Unless the
firmware gets an
OWIN/OWOUT
reset pulse or changes state, further results from image analysis are
appended to these five bytes. The area they get appended to just happens to be the 11-byte command
buffer, where buffered commands are stored. For this reason, the command buffer is only temporary
storage, and a command sequence saved there must be reloaded each time it is used.
Resetting the Driver
PBASIC’s
OWOUT
and
OWIN
commands include a provision for sending a “reset” pulse to the AVR. The
TSL1401R driver will accept this pulse anytime it’s expecting I/O from the BASIC Stamp (
and only then
)
and will use it as a signal to reset its communication state and buffer pointers to their initial conditions.
The reset pulse is most often used to terminate a sequence of result data being read from the AVR, as
the following example shows:
OWOUT owio, 0, [DUMPADR, 32] 'Begin dumping from buffer address 32.
OWIN owio, 2, [minpix, minloc, maxpix, maxloc] 'Read 4 byte variables.
Here
DUMPADR
is a command to begin dumping data from the address given by the next byte. It is
followed immediately by a read, using
OWIN
. The
OWIN
parameter
2
indicates that a reset pulse
should be sent
after
the statement is finished executing (i.e. after the four variables have been read out),
which tells the AVR to quit transmitting data.
Any time such a reset pulse is received, the internal pointer that determines where the next result is
deposited in memory is set to
$20
, the beginning of the
RESULTS
buffer. So, when you’re reading
results, make sure to read everything you need before sending a command that adds data to the buffer.
Otherwise any remaining data that you need to read might be overwritten.
There are two instances when a reset pulse will not be recognized by the driver:
•
When the driver is busy.
•
When a triggered acquisition is awaiting the trigger pulse.
In the former case, just complete the not-busy polling before resetting the firmware. The latter case is
discussed in the section, “Acquiring an Image”.