1.2 Write flag bit operation
For device flag write operations, up to 256 bytes of flag bits can be written at one time .
The content modified by the write flag operation will be lost after a power failure. If it needs to be retained after
a power failure, it is necessary to save the flag bit in the internal Flash .
Command format :
Input :
{Head1} {Types} {Lens} {Address} {Datas} {CRC}
Among them :
Head1 : 0x7E 0x00 (2 bytes)
Types : 0x08 (1 byte)
Lens : 0x00~0xFF (1 byte), it indicates the number of bytes in the Datas field in the command, and also
indicates the number of consecutive write operations to be performed, and 0x00 indicates that there are 256
bytes
Address : 0x0000~0xFFFF (2 bytes), indicating the starting address of the flag to be written
Datas : 0x00~0xFF (1~256 bytes), indicating the data to be written to the flag bit. When configuring multiple
flag bits, the data field must be filled in the order of addresses from low to high .
CRC : CRC_CCITT check value (2 bytes) .
Calculation range : The calculation method of Types, Lens, Address, and Datas is CRC_CCITT, and the
characteristic polynomial : X16+X12+X5+1, that is, the polynomial coefficient is 0x1021, and the initial value is all
0. For a single byte, the highest bit is calculated first , do not need to be inverted and output directly .
Note : When the user does not need the CRC check function, they can fill in 0xAB 0xCD in the CRC byte,
without checking .
Returns : {Head2} {Types} {Lens} {Datas} {CRC}
1) write successfully
Among them :
Head2 : 0x02 0x00
Types : 0x00 ( write successful )
Lens : 0x01
Datas : 0x00
CRC : CRC_CCITT check value (0x33 0x31)
2) Failed to deliver CRC check
no response command
3) Unknown command response
no response command
Example :
Write 0x3E to the flag bit at address 0x000A
1) Set successfully
Input : 0x7E 0x00 0x08 0x01 0x00 0x0A 0x3E 0x4C 0xCF
Returns : 0x02 0x00 0x00 0x01 0x00 0x33 0x31