Ttelmah Guest
|
|
Posted: Tue Sep 04, 2007 7:18 am |
|
|
You can't.
Not possible in the hardware. The program counter (as well as the other similar registers), are SRAM. The contents of these are only maintained, when power is applied.
Now, there are some possibilities:
1) Have a small lithium cell as a 'backup' battery, and put the PIC into a 'sleep' (power saving) mode, when power is removed. A typical PIC, without clock, will happily sit doing nothing, for several years powered by such a cell.
2) If it is not the exact code location, but what the chip was 'doing', that needs to be restored, then build your code as a state machine, and use the power-fail interrupt, to just record the state. Then when power is restored, re-initialise all the I/O, and jump directly to the stored state.
Best Wishes |
|