QG8 flash write on LVD interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

QG8 flash write on LVD interrupt

1,078 Views
glennk
Contributor I
I would like to use the LVD interrupt to save one byte of data to flash in the QG8 part when power is going down.  The flash will already be erased, so I'll only need to program the one byte as power goes down. I'm using CodeWarrior with Processor Expert.   I have two questions:
 
1. Can I write to flash from within the LVD interrupt using SetByteFlash?
 
2. What is the safest thing to do after the flash is programmed?  I don't want the code to run amuck as power goes down.  Is there any software way of forcing the chip into reset?
 
Thanks
Labels (1)
0 Kudos
2 Replies

281 Views
bigmac
Specialist III
Hello,
 
It should be feasible to program the byte value to flash within the ISR code.  Of course, the code that controls the programming process will actually be running from RAM (probably the stack).
 
After programming is complete, I guess there are a couple of possibilities -
  1. Enter a wait loop within the ISR, and rely on the COP timer to initiate a reset.
  2. Execute an illegal opcode within the ISR to immediately initiate a reset.
 
One thing you may have to guard against is the occurrence of multiple LVD interrupts should reset initialisation occur more than once for the same power event.  Ideally, the LVD should interrupt the first time, and hold a reset condition the second time.  The problem will be detecting which is first and second time.
 
Regards,
Mac
 
 
0 Kudos

281 Views
bigmac
Specialist III
Hello,
 
A further thought on the multiple interrupt/reset issue.
 
Assuming you were to cause an immediate reset using the illegal opcode method (after programming the flash byte), since the SPMSC1_LVDRE bit is set out of reset, I assume a reset condition would be held during the remainder of the power-down process.  If this be true, then multiple resets or interrups could never occur during a power "ramp down".
 
Regards,
Mac
 


Message Edited by bigmac on 2007-12-20 12:50 PM
0 Kudos