Post Go back to editing

ADE7913/7912 ADC CRC Issue

Hi all, ade7913

I am working on measurment application with ADE7913.

I have no problem with reading out data from ADC.

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 : 


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

Adam Górski

  • Forgot to specify settings. All setings same as on PowerOn.

  • 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.

    Example good readout :

    [byte rcv index] = data
    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;
    aa = 0x0000;
    fb = aa ^ b;
    if ( fb & 0x8000 )
    b = g ^ ( b << 1 );
    b |= 0x001;
    b = b << 1;

    return b;

  • Hi,

    I am glad you were able to identify the error and verify the CRC value given by the ADE7913. I am also attaching a spreadsheet you can use to do the same.

    Thank you very much


  • This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin