标题: 松翰SN8F5703单片机WDT例程 [打印本页]

作者: hexinquan    时间: 2020-12-8 11:40
标题: 松翰SN8F5703单片机WDT例程
松翰5703例程-WDT
  1. //--------------------------------------------------------------------------
  2. //Filename        : STOP_Mode.c
  3. //Function        : Use watch dog timer to Power save application when SN8F5708 run as stop mode.
  4. //description        : SN8F5708 be waked up by watch dog reset.
  5. //--------------------------------------------------------------------------
  6. //Note:
  7. //     1)User need to add the STARTUP.A51 file which in this project to your project.
  8. //     2)The STARTUP.A51 file has been modified for the Watchdog wakeup function.
  9. //     3)User need to Reset the source which has used according to the PFLAG register.
  10. //--------------------------------------------------------------------------

  11. #include <SN8F5703.h>

  12. #define uchar unsigned char
  13. #define uint unsigned int
  14.        
  15. uchar RCycle_CNT;
  16. //--------------------------------------------------------------------------
  17. //subroutine        : main()
  18. //Function                :
  19. //--------------------------------------------------------------------------
  20. void main(void)
  21. {
  22.                 CLKSEL = 0x03;                                //Fcpu=Fosc/16
  23. //        CLKSEL = 0x04;                                //Fcpu=Fosc/8
  24. //        CLKSEL = 0x05;                                //Fcpu=Fosc/4
  25.                 CLKCMD = 0x69;
  26.                 CKCON = 0x11;
  27.        
  28.                 WDTR = 0X5A;       
  29.                
  30.         if((PFLAG&0X40)==0X40)        //Watchdog Reset
  31.         {       
  32.                 P0UR = 0X00;
  33.                 P0 = 0X00;
  34.                 P0M = 0XFF;
  35.                
  36.                 P1UR = 0X00;
  37.                 P1 = 0X00;
  38.                 P1M = 0XFF;
  39.                
  40.                 P2UR = 0X00;
  41.                 P2 = 0X00;
  42.                 P2M = 0XFF;
  43.         }
  44.         else                                                                                //Other Reset
  45.         {       
  46.                 P0UR = 0X00;
  47.                 P0 = 0XFF;
  48.                 P0M = 0XFF;
  49.                
  50.                 P1UR = 0X00;
  51.                 P1 = 0X00;
  52.                 P1M = 0XFF;
  53.                
  54.                 P2UR = 0X00;
  55.                 P2 = 0X00;
  56.                 P2M = 0XFF;
  57.         }

  58.         while(1)
  59.         {
  60.                 WDTR = 0X5A;
  61.                 RCycle_CNT++;
  62.                 P2 = RCycle_CNT;                //P2 output registor data
  63.                 P1W = 0X00;                                        //Set P1 port wake up source, if enable, user need to set port as input mode
  64.                 STOP();
  65.         }
  66. }
复制代码

5703_WDT_WakeUp_20161103.rar

28.46 KB, 下载次数: 15, 下载积分: 黑币 -5


作者: tt98    时间: 2021-1-11 11:40
难道是用中文函数?




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1