VTI Instruments Corp.
334
EX1629 Onboard Memory
Some differences from the DS2430 version are also seen here. Aside from using the
DS2431_SCRATCHPAD_LEN instead of the DS2430_SCRATCHPAD_LEN, a much larger
buffer is used for the data length. This is because the echo from the command being sent and a 2-
byte CRC calculated on the returned data stream are expected in addition to the data in the
scratchpad. It can also be seen that this is also passed into our the CRC calculating function so that
the CRC can be verified. See the note in the WRITE_SCRATCHPAD_2431 section for what to do
if the CRCs do not match.
Here is some example output from this command:
sent packet without errors
Packet length: 8
07 82 0A 03 0E AA 00 85
got a packet without errors on receive
Packet length: 19
12 82 00 0A 0E AA 00 00 07 AA 02 03 04 05 06 07 08 F9 19
CRC16: F919
The CRC again checks properly.
COPY_SCRATCHPAD_2431
int copy_scratchpad_2431(int channel, int address)
{
int sendLen, recLen = 0;
sendLen = 1; // reserve first byte for length
// access the current device with address in DATA_ID
SendPkt[+] = CMD_ML_ACCESS;
// construct a block of communication to MicroLAN
SendPkt[+] = CMD_ML_DATA;
SendPkt[+] = 5; // block length
SendPkt[+] = 4; // data length
// send the copy scratchpad command
SendPkt[+] = COPY_SCRATCHPAD;
// send the validation key
if (address > (DS2431_MEMORY_LEN-DS2431_SCRATCHPAD_LEN) || address
< 0)
{
printf("Invalid scratchpad address, must be between 0 and 88
hex\n");
return -1;
}
SendPkt[+] = address;
SendPkt[+] = 0;
SendPkt[+] = 0x07;
// delay for 128ms
SendPkt[+] = CMD_DELAY;
SendPkt[+] = 1;
SendPkt[+] = DELAY_128 | DELAY_MS;
// set the length
SendPkt[0] = sendLen - 1;
// send and receive the frame
MLanHostPacketSend(SendPkt, channel);
recLen = MLanHostPacketReceive(RecPkt, channel, MLAN_PACKET_SIZE);
return recLen;
}
The COPY_SCRATCHPAD command for the DS2431 is more complicated than the DS2430
command. Here, the scratchpad address must be passed in or the device will assume it is receiving
incorrect instructions and an error will occur. (The address should be the same address passed in to
WRITE_SCRATCHPAD). The ES register must also be passed in, which should be “07”,
identical to its value in the READ_SCRATCHPAD command (if the original write was
Содержание EX1629
Страница 310: ...VTI Instruments Corp 310 EX1629 Command Set...
Страница 342: ...VTI Instruments Corp 342 EX1629 Onboard Memory...