2007-07-10 08:40 AM
2007-07-10 08:40 AM
Hello,
I need a help to create codes for enter to HALT and wake up procedures. Sure, I have creates some codes by myself, but seems its to be not correctly working. My target is to support [POWER] button on the PB0 pins, which should switch the MCU to HALT mode and wake it up by pressing the button in sequence. Below is my example of the enter to standby and wake up procedures: void GoToStandby(void) { //config PB0 pin to accept interrupt to wake up SetBit(PBDDR,0); SetBIt(PBOR,0) //config wake up condition //by falling edge on SWITCH_POWER pin //EICR[7:6]=10 for falling edge //EISR[7:6]=00 for no interrupt on PB0..PB2 //EISR[7:6]=01 for interrupt on PB0 //EISR[7:6]=10 for interrupt on PB1 //EISR[7:6]=11 for interrupt on PB2 //reinit config registers EICR=0; EISR=0; //set IE3 interrupt by the falling edge SetBit(EICR,7); ClrBit(EICR,6); //config wake up of PB0 ClrBit(EISR,7); SetBit(EISR,6); //enable interrupt by i/o EnableInterrupts(); //enter to HALT Halt(); } void EIx_IT_Routine(void) { //disable any interrupts for a while DisableInterrupts(); //delay for debounce Wait100ms(); //check if swith on PB0 has been pressed if (!ValBit(PBDR,0)) { //P0 not confirmed - back to HALT EnableInterrupts(); Halt(); } else { //disable interrupt on PB0 ClrBit(PBOR,0); //restart the program by asm jump {_asm (''jp 0xe000''); }; } Thank you, Alexander.