IBASE IBD185 User Manual
Page 8

8 IBD185 User Guide
1.2.2 Packet Format
Header Size
Command
Data
CRC
2 bytes 1 byte 1 byte
0 – 64 bytes
2 bytes
Header
bytes indicate start of the packet.
Size
specifies number of bytes for data field.
CRC
verifies data integrity for header, size, command and data bytes.
Command
identifies action, which is required to be performed on the data.
1.2.3 CRC
Protocol uses 16-bit CCITT CRC to verify data integrity.
P(x) = X16+X12+X5+1.
unsigned calc_crc(unsigned char *data, unsigned n, unsigned start)
{
unsigned I, k, q, c, crcval;
crcval=start;
for (I=0; I { c=data(I) & 0xFF; q=(crcval^c) & 0x0F; crcval=(crcval>>4)^(q*0x1081); q=(crcval^(c>>4)) & 0x0F; crcval=(crcval>>4)^(q*0x1081); } return crcval; } Communication between PC and MCU utilizes Master-Slave model, where PC is a master, and MCU is a slave. Master sends requests to the slave, and slave has to reply to them. Slave acts like a passive device and cannot send any requests to the master.
1.2.4 Communications flow