找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2704|回復(fù): 1
收起左側(cè)

松翰SN8F5703單片機WDT例程

[復(fù)制鏈接]
ID:856645 發(fā)表于 2020-12-8 11:40 | 顯示全部樓層 |閱讀模式
松翰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. }
復(fù)制代碼

5703_WDT_WakeUp_20161103.rar

28.46 KB, 下載次數(shù): 15, 下載積分: 黑幣 -5

相關(guān)帖子

回復(fù)

使用道具 舉報

ID:88606 發(fā)表于 2021-1-11 11:40 | 顯示全部樓層
難道是用中文函數(shù)?
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表