VTI Instruments Corp.
322
EX1629 Onboard Memory
The WRITE_SCRATCHPAD command can be used to write arbitrary data to the scratchpad of a
1-Wire device. Unlike the GET_URN function, WRITE_SCRATCHPAD (and all other MLAN)
functions are specific to the type of MLAN device being used. In the example code,
write_scratchpad_2430() and write_scratchpad_2431() functions are used to represent the
differences between the DS2430 and DS2431 devices. Be careful of the size differences between
various devices’ scratchpad buffers. In the case of the DS2431, 8 bytes of data, aligned on an
8-byte address, must be written together – that is, all memory writes involve 8 bytes. To modify a
single byte of memory requires that the 8-byte block be read back from the device, the byte in
question 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
Below, we will discuss the example code for each function of the 2430 and 2431. First, however,
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
Содержание EX1629
Страница 310: ...VTI Instruments Corp 310 EX1629 Command Set...
Страница 342: ...VTI Instruments Corp 342 EX1629 Onboard Memory...