SLAZ357J October 2012 – May 2021 MSP430FE427
ESP Module
Functional
Negative Energy Flag Operation
The NEGENFG negative energy flag treatment inside the ESP430 module is executed after each mains cycle and is set according to the energy accumulated during this period. Therefore the flag is set under two conditions:
- if during at least one mains cycle period over the last second the accumulated energy in the ACTENSPER register was negative
- if the accumulated energy in the ACTENERGY register is negative.
If the indication of the negative energy status is required by the application, it can be done with the following sequence in CPU software.
1. Set negative energy bits: NE0 = 0, NE1 = 1 (negative energy is summed)
2. Perform the required steps manually software after new energy samples are available from the ESP430CE1:
- Check if the energy is negative and set the negative energy flag
- Correct the energy to positive values if required.
if ((msg_data & ENRDYFG))
{
if ((ACTENERGY1_HI & 0x8000) > 0 ) {// Negative Energy measured?
negenfg = 1; // set global neg. Energy Flag
}else{
negenfg = 0; // clear global neg. Energy Flag
}
if (negenfg == 1){ // Negative Energy measured?
total_energy -= (float)energy.l;
}else{
total_energy += (float)energy.l;
}
} // End of if ((msg_data & ENRDY)