Bootloader corrupted at low voltage
I have a number of data loggers using the PIC 18LF4620 powered off a 3.6 volt Lithium Thionyl battery. There is no voltage regulator. In normal operation these wake up, note the time and temperature from a DS1629 RTC, record ten seconds of analog waveform data, store all that to ST M25P64 long term flash memory as a 2048 byte record, then go back to sleep for ten minutes.
Usually I get the back loggers before the battery goes flat and I can extract the data by loading a dump program via the MCS+ Bootloader. This last lot did not come back in time and the batteries are all flat, reading less than 0.5 volts. It looks like the bootloader has been corrupted and after removing the batteries and supplying 3.6 volts, I cannot read any data back. Six units in a row show exactly the same problem.
Are there any 'zero component' tricks that I can use to measure battery voltage when the system has no voltage reference to compare against? Is there a simple RC oscillator that varies with battery volts that I can tap into? If I can find a way to measure battery volts I can put a branch in the code to stop logging when the battery falls below 2.5 volts.
I realise that normal code operation is out the window with a flat battery but has anyone got any suggestions or strategies on how to preserve the bootloader in a low voltage scenario?
Brian
Loggers are small - no iCSP
Hi Jumper,
The data loggers are surgically implanted inside fish and small reptiles. They are quite small and I did not include the ISCP pins for size reasons. In hindsight however, I think ICSP might be the best way in future as you can always blast your way in with the ICSP programmer. The Bootloader is more convenient in most cases which is why I chose it..
Dumping data flattens the battery in a trice so I cannot dump unless I have opened up the logger and attached external power. There is little point in having the dump code in the main logger code and indeed it could be dangerous with a code runaway that could corrupt the already logged data.
I will experiment with BOR and also RCTIME and POT commands to see if I can get a voltage dependent result that can reliably indicate the battery is nearing exhaustion and halt logging.
Cheers
BrianT