Data Sheet
MS5837-02BA
Ultra Small Gel Filled Pressure & Temperature Sensor, with Stainless Steel Cap
TE CONNECTIVITY SENSORS /// MS5837-02BA 09/2017
Page 13
CYCLIC REDUNDANCY CHECK (CRC)
MS5837 contains a PROM memory with 112-Bit. A 4-bit CRC has been implemented to check the data validity in
memory.
Memory PROM mapping
C Code example for CRC-4 calculation:
unsigned char crc4(unsigned int n_prom[]) // n_prom defined as 8x unsigned int (n_prom[8])
{
int cnt; // simple counter
unsigned int n_rem=0; // crc remainder
unsigned char n_bit;
n_prom[0]=((n_prom[0]) & 0x0FFF); // CRC byte is replaced by 0
n_prom[7]=0; // Subsidiary value, set to 0
for (cnt = 0; cnt < 16; cnt++) // operation is performed on bytes
{ // choose LSB or MSB
if (cnt%2==1) n_rem ^= (unsigned short) ((n_prom[cnt>>1]) & 0x00FF);
else n_rem ^= (unsigned short) (n_prom[cnt>>1]>>8);
for (n_bit = 8; n_bit > 0; n_bit--)
{
if (n_rem & (0x8000)) n_rem = (n_rem << 1) ^ 0x3000;
else n_rem = (n_rem << 1);
}
}
n_rem= ((n_rem >> 12) & 0x000F); // final 4-bit remainder is CRC code
return (n_rem ^ 0x00);
}
MS5837-02BA
A
d
d
D
B
1
5
D
B
1
4
D
B
1
3
D
B
1
2
D
B
1
1
D
B
1
0
D
B
9
D
B
8
D
B
7
D
B
6
D
B
5
D
B
4
D
B
3
D
B
2
D
B
1
D
B
0
0
CRC
Version defined
Factory defined
1
C1
2
C2
3
C3
4
C4
5
C5
6
C6