int main(void)
{
while (1)
{
if (PORBbits.RB7 == 0) // Assume this indicates "No AC"
{
/* You may need to set your I/O pins to proper state to reduce current */
PMD1 = 0xFFFF;
PMD2 = 0xFFFF;
PMD3 = 0xFDFF; // RTCC alive
_IDLE = 1;
IDLE();
if (_IDLE == 0) // To verify that the processor indeed went to idle
LATAbits.LATA8 ^= 1; // toggle RA8 after waking up
}
}
}
The connect RB7 to the 5V AC. When power goes out, this should go to zero. Correct? That way if for any reason an interupt fires, it would go back into idle mode until power is restored.