I am working on measurment application with ADE7913.

Problem starts when I want to verify data.

I have single burst readout with IWV, V1WV, and V2WV data and I should be able to calculate and compare CRC.

So example data read out looks like :

[00]=06
[01]=53
[02]=03
[03]=05
[04]=eb
[05]=e6
[06]=06
[07]=c4
[08]=c4
[09]=2d
[0a]=f1

where [ byte number ] = data , so 11 bytes . first IWV 3 bytes , V1WV 3 bytes , V2WV 3 bytes and ADC_CRC 2 bytes.

There is certain offest at 0V but using proper calulation I am able to get proper result. So I think data is correct.

Problem starts when I want to compare CRC. I spent with datasheet long hours as well as with many online calculators.

I have found also analog tool for similar chip but same polynomial, also cannot get correct result.

I understand that using data [00..08] as data and polynomial G(x) = x16 + x12 + x5 + 1 , I should get CRC as it is [09..0a]

But no way. I already tried to swap bytes & bits in all possbile combination.

What I need ,prefferrably, is pices of C code for calculating this CRC.

There is also 2nd possibility that my data is wrong and this is my problem. Verified burst readout from ADE7913 would be also helpful to me.

to ANALOG : Shame on you. Description could be better.

Best regards

Parents
• Found reason.

Data must be sent within single conversion. If ADC conversion ends during SPI burst read, result is updated and you get half of last conversion and half of new. CRC does not match in this case. No way.

I was sure that within single burst read data is buffered and consistant. It is not.

[byte rcv index] = data
[00]=06
[01]=47
[02]=42
[03]=05
[04]=d3
[05]=e4
[06]=06
[07]=bc
[08]=fe
[09]=3a
[0a]=38
Calculated LFSR CRC 3a38

Poor optimized , based on ADE7913 datasheet mathematics C code:

uint16_t crc16_3(uint8_t *a )
{
uint8_t bit_mask[ 8 ] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 , 0x01 };
uint8_t byte_mask[ 9 ] = { 0x02, 0x01 , 0x00, 0x05, 0x04, 0x03, 0x08, 0x07, 0x06 };
uint16_t g = 0x1021; /* divisor is 16bit */
uint16_t b = 0xffff; /* CRC value is 16bit */
uint16_t aa,fb,i;

for( i = 0; i < 72; i++ )
{
if ( a[ byte_mask[ i >> 3 ] ] & bit_mask[ i % 8 ] )
aa = 0x8000;
else
aa = 0x0000;
fb = aa ^ b;
if ( fb & 0x8000 )
{
b = g ^ ( b << 1 );
b |= 0x001;
}
else
b = b << 1;
}

return b;
}

• Found reason.

Data must be sent within single conversion. If ADC conversion ends during SPI burst read, result is updated and you get half of last conversion and half of new. CRC does not match in this case. No way.

I was sure that within single burst read data is buffered and consistant. It is not.

[byte rcv index] = data
[00]=06
[01]=47
[02]=42
[03]=05
[04]=d3
[05]=e4
[06]=06
[07]=bc
[08]=fe
[09]=3a
[0a]=38
Calculated LFSR CRC 3a38

Poor optimized , based on ADE7913 datasheet mathematics C code:

uint16_t crc16_3(uint8_t *a )
{
uint8_t bit_mask[ 8 ] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 , 0x01 };
uint8_t byte_mask[ 9 ] = { 0x02, 0x01 , 0x00, 0x05, 0x04, 0x03, 0x08, 0x07, 0x06 };
uint16_t g = 0x1021; /* divisor is 16bit */
uint16_t b = 0xffff; /* CRC value is 16bit */
uint16_t aa,fb,i;

for( i = 0; i < 72; i++ )
{
if ( a[ byte_mask[ i >> 3 ] ] & bit_mask[ i % 8 ] )
aa = 0x8000;
else
aa = 0x0000;
fb = aa ^ b;
if ( fb & 0x8000 )
{
b = g ^ ( b << 1 );
b |= 0x001;
}
else
b = b << 1;
}

return b;
}

Children
No Data