感謝大家的幫助。
我用3231芯片做了個電子時鐘,想每秒讀取一次時間。讀取完成之單片機就掉電,等待下一秒3231的喚醒脈沖。這樣能最大限度的降低功耗。
我的程序掉電部分已經能夠正常去行了。準備轉戰下一個難題
我將范例程序貼出來,新手參考下,老鳥無視,主要是自我總結
INT0 = 1; //ready read INT0 port
while (!INT0); //check INT0
這兩個語很重要,一個是將INT0置1
下一句是檢測INT0是否為1,不是1就一直檢測。說明置1的重要性
當然,有的時候,不加這兩句是可以正常運行的。
以下是完整的范例程序
/*------------------------------------------------------------------*/
/* --- STC MCU Limited ---------------------------------------------*/
/* --- STC89-90xx Series MCU Power-Down wakeup by INT0 Demo --------*/
/* 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"
//External interrupt0 service routine
void exint0() interrupt 0 //(location at 0003H)
{
}
void main()
{
IT0 = 1; //set INT0 int type (1:Falling 0:Low level)
EX0 = 1; //enable INT0 interrupt
EA = 1; //open global interrupt switch
while (1)
{
INT0 = 1; //ready read INT0 port
while (!INT0); //check INT0
_nop_();
_nop_();
PCON = 0x02; //MCU power down
_nop_();
_nop_();
P1++;
}
}