I wan to be able to log (in flash) when the voltage drops into at least the warning level (better yet LVD level) and then have the micro enter reset.
It seems I can either have it enter LVD reset at this point OR get an interrupt and log the event and NOT reset.
For LVD reset (and no log) my settings are:
PMC_LVDSC1 = LVDRE, set and high trip point set.
PMC_LVDSC2 = high trip point set.
This works great, even during a brown out. When power comes back up the I2C's and UART work fine. The only problem is I cant log it in my event log, which I want to be able to do.
For LVW Interrupt and logging, my settings are:
PMC_LVDSC1 = LVDRE set, and low trip point set
PMC_LVDSC2 = LVWIE set, and high trip point set
With this I can log the event, BUT it never goes into LVD reset during a brown out, so when power comes back up the I2C's and UART don't work. I tried changing the trip points for both but the result is always the same. If the power drops down low enough (maybe it goes to 0?), and then come back up, everything is OK, but not a brownout condition.
Is there some way I can get the LVD or LVW interrupt but also have it enter LVD reset when it reaches the LVD reset trip point?
Is there a way to force it to enter LVD reset? (I'm thinking no)
I tried forcing a software reset when getting an LVD interrupt but the I2C and UART are still messed up (not working) when power comes up from a brown out. I assume because its not held in reset until power comes back up to an acceptable level.
So to summarize what I want to do:
When power drops, somehow log the event in flash.
Have the micro enter LVD reset.
When power comes back up, exit LVD reset and restart the micro.
This must work for power loss and brownout also.