标题:
松翰SN8F5703单片机WDT例程
[打印本页]
作者:
hexinquan
时间:
2020-12-8 11:40
标题:
松翰SN8F5703单片机WDT例程
松翰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();
}
}
复制代码
5703_WDT_WakeUp_20161103.rar
2020-12-8 11:40 上传
点击文件名下载附件
下载积分: 黑币 -5
28.46 KB, 下载次数: 15, 下载积分: 黑币 -5
作者:
tt98
时间:
2021-1-11 11:40
难道是用中文函数?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1