P0口的数码管显示是试过正常的,本想加个看门狗试试看,但是没有看到有什么反应!!!!麻烦帮忙看看,谢谢!!!!
#include "reg51.h"
#define uchar unsigned char
#define uint unsigned int
sfr WDT_CONTR=0xe1;
sbit button= P3^0;
sbit p27=P2^7;
uchar code disptab[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x27,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(uchar x);
uchar
time0,time1;
void main()
{
uchar a;
TMOD=0x01;
TH0=(65536-16000)%256;
TL0=(65536-16000)/256;
TR0=1;
EA=1;
ET0=1;
// p27=1;
P0=0;
p27=0;
a=0;
WDT_CONTR=0x3C;
// DWT_CONTR=0X2F;
while(1)
{
if(button==0)
{
TR0=0;
}
if(a==16)
a=0;
P0=disptab[a];
delay(100);
a++;
time0=0;
}
}
void delay(uchar x)
{
uint y;
for(;x>0;x++)
for(y=0;y<1000;y++);
}
void time() interrupt 1
{
TH0=(65536-16000)%256;
TL0=(65536-16000)/256;
time0++;
WDT_CONTR=0x3C;
}
一周热门 更多>