EasyManua.ls Logo

VTI Instruments EX1629 - Copy_Scratchpad_2430

Default Icon
346 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
VTI Instruments Corp.
328 EX1629 Onboard Memory
Here is some example output from READ_SCRATCHPAD using the example code:
sent packet without errors
Packet length: 8
07 82 0A 03 22 AA 00 85
got a packet without errors on receive
Packet length: 39
26 82 00 0A 22 AA 00 AA 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10
11 12 13 14
15 16 17 18 19 1A 1B 1C 1D 1F 20 21
This is identical to what was written with the WRITE_SCRATCHPAD command, so the data was
written properly. Again, recall that the non-atomic operations cannot be guaranteed, as the 1-Wire
devices are powered down between MLAN commands, which erases the scratchpads.
COPY_SCRATCHPAD_2430
The COPY_SCRATCHPAD command is the only method for writing data to the memory of a
MLAN device; it copies the data in the scratchpad to the non-volatile memory. Like
READ_SCRATCHPAD, the command is fairly simple, as the data already exists and only needs
to be moved.
int copy_scratchpad_2430(int channel)
{
int sendLen, recLen = 0;
sendLen = 1; // reserve first byte for length
// access the current device with address in DATA_ID
SendPkt[sendLen++] = CMD_ML_ACCESS;
// construct a block of communication to MicroLAN
SendPkt[sendLen++] = CMD_ML_DATA;
SendPkt[sendLen++] = 3; // block length
SendPkt[sendLen++] = 2; // data length
// send the copy scratchpad command
SendPkt[sendLen++] = COPY_SCRATCHPAD;
// send the validation key
SendPkt[sendLen++] = 0xA5;
// delay for 128ms
SendPkt[sendLen++] = CMD_DELAY;
SendPkt[sendLen++] = 1;
SendPkt[sendLen++] = DELAY_128 | DELAY_MS;
// request the result buffer as the last command
SendPkt[sendLen++] = CMD_GETBUF;
// set the length
SendPkt[0] = sendLen - 1;
// send and receive the frame
MLanHostPacketSend(SendPkt, channel);
recLen = MLanHostPacketReceive(RecPkt, channel, MLAN_PACKET_SIZE);
return recLen;
}
Once again, the first three bytes are the same as WRITE_SCRATCHPAD and
READ_SCRATCHPAD. Our block length is 3, as the expected response length, the
COPY_SCRATCHPAD command, and the “validation keythat ensures we are not writing to the
wrong device are sent. Each “family” of MLAN device has a different validation key. This will be
seen with the DS2431. Note that the expected response length is the minimum 2 bytes. Since the
COPY_SCRATCHPAD command does not actually return data to us, space does not have to be
allocated in the return buffer.

Table of Contents

Related product manuals