我的E文不好,请大虾帮帮忙啦,我的程序在这里:
#include /* for EnableInterrupts macro */
#include /* include peripheral declarations */
#define Enable EnableInterrupts
#define Disable DisableInterrupts
unsigned int RT;
unsigned char RTtmp;
unsigned char count;
unsigned char addr;
unsigned char value;
unsigned char Code[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x00,0xC6,0x40,0x46,0x8E};
void sysinit(void)
{
Disable;
CONFIG1=0X01;
DDRB=0xFF;
PTB=0x00;
DDRD=0xF0;
PTD=0x00;
ADICLK=0x70;
ADSCR=0x28;
}
void delay(void)
{
unsigned int i;
for(i=0;i<100;i++);
}
void Sendled(addr,value)
{
switch(addr)
{
case 1:
PTD=0XE0;
PTB=Code[value];
break;
case 2:
PTD=0XD0;
PTB=Code[value];
break;
case 3:
PTD=0XB0;
PTB=Code[value];
break;
case 4:
PTD=0X70;
PTB=Code[value];
break;
}
}
void Displayled(void)
{
Sendled(1,RT/1000%10);
delay();
Sendled(2,RT/100%10);
delay();
Sendled(3,RT/10%10);
delay();
Sendled(4,RT%10);
delay();
}
void main(void)
{
sysinit();
delay();
Enable;
while(1)
{
unsigned char TMP[]={0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,
100,100,100,100,100,100,100,100,100,100,//11-20
100,100,100,100,100,100,100,100,100,100,//21-30
100,100,100,100,100,100,100,100,100,100,//31-40
100,99,98,97,96,95,94,93,92,91,//50
90,89,88,87,86,85,85,84,86,82,//60
81,81,80,79,79,78,77,77,76,75,//70
74,74,73,72,71,71,70,69,69,68,//80
68,67,67,66,66,65,65,64,64,63,//90
62,62,61,61,60,60,59,59,58,57,//100
57,56,56,55,55,54,54,53,53,52,//110
52,51,51,50,50,49,49,48,48,48,//120
47,47,46,46,45,45,44,44,43,43,//130
42,42,42,41,41,40,40,40,39,39,//140
38,38,37,37,36,36,35,35,34,34,//150
33,33,32,32,31,31,31,30,30,30,//160
28,28,27,27,26,26,25,25,24,24,//170
23,23,22,22,20,20,19,19,18,18,//180
17,17,16,16,15,15,14,14,13,13,//190
12,12,11,11,10,10, 9, 9, 8, 8,//200
7, 7, 6, 6, 5, 5, 4, 4, 3, 3,//210
2, 2, 1, 1, 1, //215
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//225
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//235
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,//245
0, 0, 0, 0, 0,0xcc,0xcc,0xcc,0xcc,0xcc //255
};
__RESET_WATCHDOG();
Displayled();
count++;
if(count==20)
{
count=0;
RT=TMP[ADR];
}
}
} |