VTI Instruments Corp.
APPENDIX C
94
modified, and the resulting 8 bytes written back. The datasheet for the 1-wire component in use
should serve as the ultimate guide in programming the device.
The READ_SCRATCHPAD function can be used to read back a device’s scratchpad. For example,
it is always a good idea to do this after a WRITE_SCRATCHPAD call and before a
COPY_SCRATCHPAD call to verify that the write was completed successfully and that the data
was entered correctly before permanently overwriting main memory. As previously noted, using the
individual functions for WRITE, READ, and COPY can cause data loss and the recommended
method is to use the WRITE_AND_COPY command and read main memory.
COPY_SCRATCHPAD allows the user to transfer the scratchpad buffer on the MLAN device to
the non-volatile memory of the device. This permanently overwrites the addressed non-volatile
memory, so care should be exercised when doing so.
P
ROGRAMMING
MLAN
The Digitizer and DSA drivers provide access to TEDS on a per-channel basis. First, TEDS must
be enabled on the desired channel by setting the
Channel.TEDS.Enabled
property to True. Only one
channel per card can have TEDS enabled at a time. All other channels must be set to False. After
this occurs, the
Channel.TEDS
interface’s
ReadURN()
,
WriteTEDS()
, and
ReadTEDS()
functions
can be used. The
WriteTEDS()
and
ReadTEDS()
functions allow the EMX-4250/4350/4380 card to
act as an MLAN Repeater (see Maxim APPLICATION NOTE 2966 for the MLAN Repeater
specification). Use
WriteTEDS()
to send MLAN command strings and use
ReadTEDS()
to read the
response.
ReadURN()
is a convenience function that implements the MLAN commands for
identifying the first TEDS device on the 1-wire bus. This allows simple applications that only have
to read the URN of a single device for each channel to function without having to construct the
MLAN command for discovery and identification every time.
Below, example code for each function of the 2430 and 2431 is discussed. The code example shown
here is for the purpose of discussion. Up-to-date example codes are installed with the Digitizer and
DSA driver.
First, there are some constants which should be discussed.
//MLAN commands
#define CMD_RESET 0x84
#define DATA_SEARCH_STATE 0x01
#define DATA_SEARCH_CMD 0x02
#define CMD_ML_DATA 0x0A
#define CMD_ML_RESET 0x80
#define CMD_ML_SEARCH 0x81
#define DATA_ID 0x00
#define CMD_GETBUF 0x85
#define CMD_ML_ACCESS 0x82
#define CMD_DELAY 0x0B
#define CMD_ML_BIT 0x09
#define DELAY_128 0x02
#define DELAY_MS 0x80
These #defines are commands that are sent to the MLAN controller. They do not modify the data
on the device, but allow a device to be selected, tells the controller to return a buffer with the result,
or sets up a delay on the MLAN line. They will be explained when they are used in the example
code. These commands are defined by the MLAN specification. In general, these commands are
targeted at the MLAN repeater (1-wire bus master) itself, not the 1-wire, TEDS devices.
//Functions that modify TEDS data
#define WRITE_SCRATCHPAD 0x0F
#define READ_SCRATCHPAD 0xAA
#define COPY_SCRATCHPAD 0x55
#define READ_MEMORY 0xF0