|
- #include <SN8F5703.h>
- #include <intrins.h> // for _nop_
- #define KEY1 P06 //唤醒
- #define KEY2 P10 //切换MODE
- unsigned char R_temp;
- unsigned char i;
- bit F_mode;
- /////////////////////////////////////////////////////////////////////////////
- void main(void)
- {
- CLKSEL = 0X06; //Fcpu = Fhosc/2
- CLKCMD = 0x69;
- CKCON = 0X11; //Finstruction=Fcpu/2;
-
- WDTR = 0x5A; // clear watchdog if watchdog enable
-
- P0 = 0X00;
- P1 = 0X00;
- P2 = 0X00;
-
- P0M = 0X00;
- P1M = 0X00;
- P2M = 0X00;
-
- P0UR = 0XFF;
- P1UR = 0XFF;
- P2UR = 0XFF;
-
- F_mode = 0;
-
- while(1)
- {
- WDTR = 0x5A; // clear watchdog if watchdog enable
-
- R_temp = 255;
- while(--R_temp)
- {
- if(KEY2)
- {
- R_temp = 255;
- break;
- }
- }
- if(R_temp==0)
- {
- if(F_mode==0)
- {
- F_mode = 1;
- PCON |= 0X02; //STOP MODE PCON.1
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- }
- else
- {
- F_mode = 0;
- PCON |= 0X01; //IDLE MODE PCON.0
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- }
- }
-
-
- }
-
复制代码 |
|