標(biāo)題:
STC12C5A60S2單片機(jī)怎么檢測(cè)到斷電?
[打印本頁(yè)]
作者:
漢神俊
時(shí)間:
2019-7-24 14:51
標(biāo)題:
STC12C5A60S2單片機(jī)怎么檢測(cè)到斷電?
STC12C5A60S2 怎么檢測(cè)到斷電 馬上保存
void lvdint() interrupt 6 //(location at 0033H)
{
}
我的中斷操作為什么不停生效 PCON & 0x20也一直是true
作者:
漢神俊
時(shí)間:
2019-7-24 15:20
或者有什么斷電保存的方法 提供一下也行
作者:
angmall
時(shí)間:
2019-7-24 17:04
你這個(gè)P4.6口有接嗎?
STC12C5A60S2-LVD.jpg
(249.15 KB, 下載次數(shù): 46)
下載附件
2019-7-24 17:01 上傳
我給你來(lái)個(gè)程序試試
/*------------------------------------------------------------------*/
/* --- 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++;
}
}
復(fù)制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1