标题:
STC12C5A60S2单片机怎么检测到断电?
[打印本页]
作者:
汉神俊
时间:
2019-7-24 14:51
标题:
STC12C5A60S2单片机怎么检测到断电?
STC12C5A60S2 怎么检测到断电 马上保存
void lvdint() interrupt 6 //(location at 0033H)
{
}
我的中断操作为什么不停生效 PCON & 0x20也一直是true
作者:
汉神俊
时间:
2019-7-24 15:20
或者有什么断电保存的方法 提供一下也行
作者:
angmall
时间:
2019-7-24 17:04
你这个P4.6口有接吗?
STC12C5A60S2-LVD.jpg
(249.15 KB, 下载次数: 46)
下载附件
2019-7-24 17:01 上传
我给你来个程序试试
/*------------------------------------------------------------------*/
/* --- STC MCU Limited ---------------------------------------------*/
/* --- STC12C5Axx Series MCU Power-Down wakeup by LVD(P4.6) Demo ---*/
/* --- Mobile: (86)13922805190 -------------------------------------*/
/* --- Fax: 86-0513-55012956,55012947,55012969 ---------------------*/
/* --- Tel: 86-0513-55012928,55012929,55012966----------------------*/
/* If you want to use the program or the program referenced in the */
/* article, please specify in which data and procedures from STC */
/*------------------------------------------------------------------*/
#include "reg51.h"
#include "intrins.h"
sfr WAKE_CLKO = 0x8f;
sfr P4SW = 0xbb;
sbit ELVD = IE^6;
//External interrupt0 service routine
void lvdint() interrupt 6 //(location at 0033H)
{
PCON &= 0xdf; //clear LVD flag
}
void main()
{
P4SW &= 0xbf; //Set P4.6 as LVD function pin
WAKE_CLKO = 0x08; //enable LVD signal wakeup MCU from power-down mode
ELVD = 1; //enable LVD interrupt
EA = 1; //open global interrupt switch
while (1)
{
while (PCON & 0x20)
{
PCON &= 0xdf; //clear LVD flag
_nop_();
_nop_();
_nop_();
_nop_();
}
_nop_();
_nop_();
PCON = 0x02; //MCU power down
_nop_();
_nop_();
P1++;
}
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1