Download Print this page

Reading Data - Parallax TSL1401-DB Instructions Manual

Linescan camera module

Advertisement

Reading Data

Data can be read from the AVR using various forms of the dump command. The first is the DUMPID
command, which reads the firmware ID and version number. Its format is:
DUMPID is a constant defined in the code template at the end of this section that has the value $DD.
(In all code examples that follow, we shall use the defined constants, since they make the code so much
more readable. It also makes the code more adaptable, in case the firmware gets upgraded and the hex
commands change.) After sending it to the AVR using OWOUT, you can read three bytes of data: two of
them are the letters "L" and "S" (for linescan); the last is just a byte (the version number), which, for this
version, is 1. Here's a snippet of code that reads and displays the firmware ID:
OWOUT owio, 0, [DUMPID]
OWIN owio, 0, [Ltr1, Ltr2, Ver]
DEBUG "Firmware version: ", Ltr1, Ltr2, DEC Ver
Ltr1, Ltr2, and Ver are Byte variables. When executed, the DEBUG screen should display:
The next dump command is DUMPFLAGS whose format is simply:
This command allows the PBASIC program to read one byte which contains various error flag bits that
can be used for debugging. The format of the flag byte is as follows:
Bit 7
BADCMD
The four most-significant bits are the error flags. A flag bit is set to 1 if its associated error has occurred
since the last time DUMPFLAGS was executed. (When DUMPFLAGS is executed, all the error flags are
cleared internally.)
BADCMD is defined in the code template as $80. It can be ANDed with the flags byte to test
whether the AVR has received an unrecognized command.
CANTBUF is defined as $40. It can be ANDed with the flags byte to test whether an attempt
was made to buffer a command (ACQGRAY or any of the dump commands) that can't be
buffered.
CMDOVF (command overflow) is defined as $20. When ANDed with the flags byte, it will tell
you if an attempt was made to buffer more than 11 bytes of commands in the command/data
buffer.
DATOVF (data overflow) is defined as $10. When ANDed with the flags byte, it shows whether
an attempt was made to buffer too many results in the command/data buffer.
Whenever an error condition occurs, the driver firmware will not permit further operations to be
performed until a reset is received. Under these conditions, if you execute a DUMPADR before sending a
reset, you will read a result equal to $FF. Since the last four bits of the result are supposed to be zero,
you will know something is wrong and can then send a reset, followed by another DUMPFLAGS
command to see what the error was. Here's the code that performs the aforementioned tasks:
© Bueno Systems, Inc. • TSL1401-DB (2009.10.01)
Firmware version: LS1
Bit 6
Bit 5
CANTBUF
CMDOVF
DUMPID
DUMPFLAGS
Bit 4
Bit 3
DATOVF
0
Bit 2
Bit 1
Bit 0
0
0
0
Page 26 of 52

Advertisement

loading
Need help?

Need help?

Do you have a question about the TSL1401-DB and is the answer not in the manual?