// File : m11_power.c #include char timer0_flag; char int0_flag; char wdt_flag; void init() { timer0_flag = 0; int0_flag = 0; wdt_flag = 0; TMOD = 0x02; TH0 = 0x10; TF0 = 0; ET0 = 1; TR0 = 1; EA = 1; } void init_interrupt() { IE0 = 0; IT0 = 0; EX0 = 1; EA = 1; } void init_wdt() { // // Initialize wdt mode // WD1 = 0; WD0 = 0; // // Restart wdt counter // RWT = 1; // // set wdt mode // WD1 = 1; WD0 = 0; // // enable wdt interrupt // EWDT = 1; } void main() { init(); PCON |= 0x01; // set IDLE mode while(!timer0_flag); init_interrupt(); PCON |= 0x02; // set STOP mode 1 while(!int0_flag); init_wdt(); PCON |= 0x02; // set STOP mode 2 while(!wdt_flag); while(1); } void timer0_int(void) interrupt TF0_VECTOR { timer0_flag = 1; TF0 = 0; TR0 = 0; } void int0_int() interrupt IE0_VECTOR { int0_flag = 1; IE0 = 0; } void wdt_int() interrupt WDT_VECTOR { wdt_flag = 1; WDIF = 0; }