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)
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);
//send first the ADE90xx address byte
//Send Read Command
//send LS byte of address
//ADE90xx comm data format: MSB--LSB ; So need send out the MSB first.
//enable back the interrupts because the communcation has finished
uc_Read_Dara[us_iCounter] = *puc_Reg_Data;
us_iAddress = Checkcrc16(uc_Read_Dara, us_Nr_Bytes-2);
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 ;
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) Can i verify my VRMS,IRMS etc values with Checksum or i can just read MASK0, MASK1, CONFIG, gain , MMODE, LCYCMODE etc. registers ? IRMS and VRMS are dynamic and not included in the checksum.
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 ? Doing the checksum manually is really not possible there are internal registers included. The preferred method is to reset part, write registers and verify, read checksum register. This is the Checksum. you can store this off in the micro for periodic comparison or enable teh checksum IRQ which will indicate a change.
3) Do i need to write CRC function or code block to verify my readings ? no you can use the crc engine in the part to compute crc for given values if you modify registers in normal operation. Save these off for comparison. If all registers read back correctly but checksum is wrong internal registers have changed and reset is required.
4) What is main difference between SPI read and Checksum read ? SPi read is a spi read. Spi read is used to read the checksum register.
5) Actually there is explanation 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. J is a bit in the 2272 bits used to calculate the checksum internally. see figure 100
6) When we read any register , do we need to check all of them with CHECKSUM register ?No, during a write to a register after verification of register values a checksum is calculated by the part. If this checksum changed and you did not perform a write something changed and reset and re configure registers is recommended.
Mr. Smith thank you for your answers,
For 2'th question :
dave.smith said:The preferred method is to reset part
You are mentioning about "reset ADE7880 chip" as "reset part", right ?
For 3'rd question :
dave.smith said:you can use the crc engine in the part to compute crc for given values
Where is the compute crc for given values part sir ?
For 6'th question :
how can i calculate my CHECKSUM values ? Which steps that i follow, can you explain briefly ?
Thank you :)
Question 2 : If checksum has unexpectedly changed.... resetting the ADE7880 by reset pin or software reset puts the ADE in a known state then reconfigure the registers.
Question 3: After you configure the registers and read back register values to verify everything is correct. The checksum register will contain the new checksum. You can now using this to verify if the checksum has changed by enabling the IRQ or reading the checksum periodically.
Question 4: See question 3. There are register values that are not available to the user used in the checksum calculations. You need to use the checksum calculated by the part. Read this and store it off for comparison if needed. The preferred method is to enable the IRQ and if IRQ is generated reset the ADE and reconfigure. This will be faster than reading all the registers to see if you can find the bad value and rewriting. If the register that changed is a non user accessible register, you will still need to reset and reconfigure.