ADE7880 CHECKSUM Read

Hi,

I am newbie on ADE7880 and trying to reach ADE7880 Checksum verification for STM32 MCU with SPI protocol of ADE7880 for my readings.

I saw this text line on datasheet : 

The registers covered by this register are MASK0, MASK1, COMPMODE, gain, CFMODE, CF1DEN, CF2DEN, CF3DEN, CONFIG, MMODE, ACCMODE, LCYCMODE, HSDC_CFG, all registers located in the DSP data memory RAM between Address 0x4380 and Address 0x43BE and another eight 8-bit reserved internal registers that always have default values. 

There is no VRMS,IRMS registers between 0x4380 and 0x43BE , there are some offset values between two.

And also,on datasheet G(x) = x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 i saw this polynomial for IEEE802.3 standard, for my readings , g0 = g1 = g2 = g4 = g5 = g7 = g8 = g10 = g11 = g12 = g16 = g22 = g26 = 1  and all of the other gi coefficients are equal to 0 but in here there is no x23 and x32.

Lets say  x = 1,

G(x) = 0x04c11db7 

but  g0 = g1 = g2 = g4 = g5 = g7 = g8 = g10 = g11 = g12 = g16 = g22 = g26 = 1  ( not x23, and x32 )

G(x) = 0x04411db7 ( if i dont add x23 and x32 )

uint16_t Read_ADE9000_CRC_SPI(uint16_t  us_ADE_Addr, uint16_t us_Nr_Bytes, uint8_t *puc_Reg_Data)
{
	uint16_t us_iCounter;
	uint16_t us_iAddress;  	
	uint8_t  uc_LS_Addr,uc_MS_Addr;
	uint8_t uc_Read_Dara[4];

	us_iAddress = us_ADE_Addr;
	us_iAddress = (us_iAddress << 4);
	us_iAddress = (us_iAddress | 0x08);
	

  	uc_LS_Addr = (uint8_t) us_iAddress;
	uc_MS_Addr =(uint8_t) (us_iAddress >> 8);
	
	SPI_Delay(ADE9000_Start_Delay_Value); 
	Enable_ADE_CS;	
	//send first the ADE90xx address byte
	SPI_Delay(ADE9000_Start_Delay_Value); 

	//Send Read Command
	SPI_MCUWriteByte(uc_MS_Addr);

	
	//send LS byte of address
	SPI_MCUWriteByte(uc_LS_Addr);


	//ADE90xx comm data format: MSB--LSB ; So need send out the MSB first.
	puc_Reg_Data=puc_Reg_Data+(us_Nr_Bytes-1);

	for (us_iCounter=0;us_iCounter<us_Nr_Bytes;us_iCounter++)
	{
		*puc_Reg_Data=SPI_MCUReadByte();
		puc_Reg_Data--;
	 }
	High_ADE_MOSI;
	Disable_ADE_CS;;
	SPI_Delay(ADE9000_Comu_Delay_Value);  
	//enable back the interrupts because the communcation has finished
	//__enable_interrupt();

	puc_Reg_Data=puc_Reg_Data+us_Nr_Bytes;
	for (us_iCounter=0;us_iCounter<us_Nr_Bytes-2;us_iCounter++)
	{
		uc_Read_Dara[us_iCounter] = *puc_Reg_Data;
		puc_Reg_Data--;
	 }
	
	us_iAddress = Checkcrc16(uc_Read_Dara, us_Nr_Bytes-2);

	return us_iAddress;
}


uint16_t  Checkcrc16( uint8_t puc_pCheck_Data[],  uint16_t  us_Nr_Bytes)
    {
          uint8_t  uc_b  =   0 ;
          uint16_t  us_crc  =   0xffff ;
          uint16_t  uc_i, uc_j;
 
          for (uc_i = 0 ; uc_i < us_Nr_Bytes; uc_i ++ )
            {        
                  for (uc_j = 0 ; uc_j < 8 ; uc_j ++ )
                    {
                        uc_b  =  ((puc_pCheck_Data[uc_i] << uc_j) & 0x80 )  ^  ((us_crc & 0x8000 ) >> 8 );
                         
                         us_crc <<= 1 ;
 
                          if (uc_b != 0 )        us_crc ^= 0x1021 ;
                 }  
         }  
 
         return us_crc;
 }

I have some questions:

1) Can i verify my VRMS,IRMS etc values with Checksum or i can just read MASK0, MASK1, CONFIG, gain , MMODE, LCYCMODE etc. registers ? 

2) I read ADE9000 Datasheet to understand CRC coding principle and i reached algorithm for CRC above but code sample is not useful for ADE7880 because the ADE7880 has  checksum 32-bit register. I need 32bit CRC Checksum reading algorith , do i ?

3) Do i need to write CRC function or code block to verify my readings ? 

4) What is main difference between SPI read and Checksum read ? 

5) Actually there isexplaination for this : Equation 54, Equation 55, and Equation 56 must be repeated for j = 1, 2, …, 2272. I am confused, if you help me i will be glad. 

6) When we read any register , do we need to check all of them with CHECKSUM register ?

Thanks a lot !


NOTE : After hardware reset I am getting default value with these methods :

a) ADE_RESET pin low-high-low step

b) SPI Selection with CS pin toggle high-to-low three times

c) Now we are ready for read CHECKSUM register to take default value : 0xAFFA63B9 result,




+1
[edited by: Mr.Alper at 2:42 PM (GMT 0) on 7 Oct 2019]
Parents Reply Children
No Data