Quote Originally Posted by Acetronics View Post
Hi, Peu

NO, you did not understand ...

1) You enable BODEN, nothing else required ...

2) AT program start, you first read the BOR bit

3) If BOR Bit = 1 THEN (and only IF ) you increase the EEPROM content : That means power is back, and did not reach ZERO !!! ( no Pb to write , then ...)

4) If BOR Bit = 0 power has gone to ZERO ( and BOR bit has been cleared ) ... just read the EEPROM content .

5) you run your "lighting" program ...

Think simple !!!

Alain
Im kinda lost again:

From TABLE 9-6: INITIALIZATION CONDITION FOR SPECIAL REGISTERS
PCON is initialized with %00000010 (POR=1 BOD=0)
From 2.2.2.6 PCON Register
REGISTER 2-6: PCON — POWER CONTROL REGISTER (ADDRESS: 8Eh)

bit 0 BOD: Brown-out Detect STATUS bit
1 = No Brown-out Detect occurred
0 = A Brown-out Detect occurred (must be set in software after a Brown-out Detect occurs)
From these datasheet entries I dont understand when BOD goes to 1