Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RTCC battery backup w/sleep

Status
Not open for further replies.
Okay, parts are on order. I believe I want to go into idle mode instead of sleep. It looks like I need the following code:
Code:
#define Idle() {__asm__ volatile (pwrsav #1);}

Idle();  //enter idle mode

However how do I look for the switchover in power from AC to the battery?
 
Could I do this:
Code:
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top