|
松翰5703例程-WDT
- //--------------------------------------------------------------------------
- //Filename : STOP_Mode.c
- //Function : Use watch dog timer to Power save application when SN8F5708 run as stop mode.
- //description : SN8F5708 be waked up by watch dog reset.
- //--------------------------------------------------------------------------
- //Note:
- // 1)User need to add the STARTUP.A51 file which in this project to your project.
- // 2)The STARTUP.A51 file has been modified for the Watchdog wakeup function.
- // 3)User need to Reset the source which has used according to the PFLAG register.
- //--------------------------------------------------------------------------
- #include <SN8F5703.h>
- #define uchar unsigned char
- #define uint unsigned int
-
- uchar RCycle_CNT;
- //--------------------------------------------------------------------------
- //subroutine : main()
- //Function :
- //--------------------------------------------------------------------------
- void main(void)
- {
- CLKSEL = 0x03; //Fcpu=Fosc/16
- // CLKSEL = 0x04; //Fcpu=Fosc/8
- // CLKSEL = 0x05; //Fcpu=Fosc/4
- CLKCMD = 0x69;
- CKCON = 0x11;
-
- WDTR = 0X5A;
-
- if((PFLAG&0X40)==0X40) //Watchdog Reset
- {
- P0UR = 0X00;
- P0 = 0X00;
- P0M = 0XFF;
-
- P1UR = 0X00;
- P1 = 0X00;
- P1M = 0XFF;
-
- P2UR = 0X00;
- P2 = 0X00;
- P2M = 0XFF;
- }
- else //Other Reset
- {
- P0UR = 0X00;
- P0 = 0XFF;
- P0M = 0XFF;
-
- P1UR = 0X00;
- P1 = 0X00;
- P1M = 0XFF;
-
- P2UR = 0X00;
- P2 = 0X00;
- P2M = 0XFF;
- }
- while(1)
- {
- WDTR = 0X5A;
- RCycle_CNT++;
- P2 = RCycle_CNT; //P2 output registor data
- P1W = 0X00; //Set P1 port wake up source, if enable, user need to set port as input mode
- STOP();
- }
- }
复制代码 |
|