Lockedwake up problem

Post
IUMO
Junior Member
2009/08/28 08:36:46
hi all!
I'm trying to wake up a PIC32MX440F512H using the change notice pins but without good results.
My idea is to press a button that puts the pic in sleep mode and it works perfectly, then, press anotther button to wake it up, but it doesn't.
I've read all related posts to this topic and I took all suggestions.

What can be the problem?

Thanks
IUMO
Junior Member
RE: wake up problem 2009/08/28 08:40:07
My code is here:

   
mINTDisableSystemMultiVectoredInt();

    // *** Buttons ***
    mPORTBSetPinsDigitalIn(BIT_4);
    mPORTBSetPinsDigitalIn(BIT_5);
    mPORTBSetPinsDigitalIn(BIT_15);
    mPORTDSetPinsDigitalIn(BIT_4);
    mPORTDSetPinsDigitalIn(BIT_5);
    mPORTDSetPinsDigitalIn(BIT_6);

    // setup the change notice options
    mCNOpen(CN_ON | CN_IDLE_CON, CN6_ENABLE | CN7_ENABLE | CN12_ENABLE | CN13_ENABLE | CN14_ENABLE | CN15_ENABLE, CN6_PULLUP_ENABLE | CN7_PULLUP_ENABLE | CN12_PULLUP_ENABLE | CN13_PULLUP_ENABLE | CN14_PULLUP_ENABLE | CN15_PULLUP_ENABLE);

    // read port(s) to clear mismatch
    mPORTBReadBits(BIT_5);
    mPORTBReadBits(BIT_4);
    mPORTBReadBits(BIT_15); //arriba
    mPORTDReadBits(BIT_4);
    mPORTDReadBits(BIT_5);
    mPORTDReadBits(BIT_6); //ENT

    // clear change notice interrupt flag
    ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_7);

      INTEnableSystemMultiVectoredInt();


and the ISR for the CN interrupts:


void __ISR(_CHANGE_NOTICE_VECTOR, ipl7) ChangeNoticeHandler(void)
{
    int valor;

    valor = mPORTDReadBits(BIT_6); //abajo
    if(!valor)
    {
       // Switch oscillator to SOSC
     OSCConfig(OSC_SOSC, 0, 0, 0);
    mOSCSetPBDIV(OSC_PB_DIV_1);

    ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_7); // Clear the CN interrupt flag
    CNCONCLR = 0x0000A000; // Device will enter SLEEP mode

    OSCCONSET = 0x10; // Device will enter SLEEP mode
    PowerSaveSleep();  
    }

// Read PORTB to clear CN mismatch condition
    mPORTBReadBits(BIT_5);
    mPORTBReadBits(BIT_4);
    mPORTBReadBits(BIT_15); //arriba
    mPORTDReadBits(BIT_5); //ENT

    IFS1CLR  = 0x0001; // Be sure to clear the CN interrupt status
}

Deenayd
Super Member
RE: wake up problem 2009/08/30 22:22:24
Your problem is that you trust Microchip's library. I have told here and there many times that somebody should REALLY check ALL those register "defines". CN_IDLE_CON / CN_IDLE_STOP are reversed.
IUMO
Junior Member
RE: wake up problem 2009/08/31 08:38:16
Thank you!
It's working perfectly now :)

My really big problem is that I have PICkit2 and it's not supported for debugging with PIC32 so I can't watch registers.