你这个P4.6口有接吗?
我给你来个程序试试
- /*------------------------------------------------------------------*/
- /* --- 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++;
- }
- }
复制代码
|