|
通电后进入掉电模式,电流大概4uA,
按键后,中断唤醒,电流大概30mA,
然后!!!!!
理论上讲这时候应该重新变成掉电模式的4uA
但是用万用表测电流发现,电流从30mA跳到28mA后,以0.1mA每秒的速度往下掉
这是为什么呀?
单片机源程序如下:
unsigned char key0 = 1;
unsigned char key1 = 1;
unsigned char key_tc = 1;
/**************中断******************/
void INT0_Routine()interrupt 0 //左边key0
{
PCON = 0x00;
key1 = 0;
}
void INT1_Routine()interrupt 2 //右边key1
{
key0 = 0;
}
void INT3_Routine()interrupt 11
{
key_tc = 0;
}
/**************主程序****************/
void main()
{
P1M1 = 0xCF; // 1.7,1.6,1.3,1.2,1.1,1.0高阻输入
P1M0 = 0x00; //
P3M1 = 0x0C; // key1和key2高阻输入
P3M0 = 0x00;
IT0 = 1; //使能INT0下降沿中断
EX0 = 1; //使能INT0中断
IT1 = 1; //使能INT1下降沿中断
EX1 = 1; //使能INT1中断
INTCLKO = 0x20; //使能INT3下降沿中断
ES = 1; //使能串口中断
EA = 1;
led = 1;
PCON = 0x02; //掉电模式,低功耗模式
while(1)
{
if(key_tc == 0)
{
led = 0;
Delay30ms(); //按键防抖
up();
read_id();
Delay30ms();
led = 1;
key_tc = 1;
PCON = 0x02;
}
if(key0 == 0)
{
led = 0;
Delay30ms(); //按键防抖
up();
Delay30ms();
led = 1;
key0 = 1;
PCON = 0x02;
}
if(key1 == 0)
{
led = 0;
Delay30ms(); //按键防抖
down();
Delay30ms();
led = 1;
key1 = 1;
PCON = 0x02;
}
}
}
|
|