本人对C一点也不懂,希望能帮我翻译一下这一段小程序每行的意思!是实现中断计数的!谢谢了!
#include <reg52.h>
#define data_port P0
sbit wei1=P2^6;
sbit wei2=P2^7;
unsigned char code DAT[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//共阴数码管显示码
unsigned char display_buffer[2]={0,0};
void delay_ms(void)
{
unsigned char i,j;
for(i=0;i<10;i++)
for(j=0;j<112;j++);
}
void display(void)
{
wei1=0;wei2=1;
data_port=DAT[display_buffer[0]];
delay_ms();
wei1=1;
wei2=1;
wei2=0;
data_port=DAT[display_buffer[1]];
delay_ms();
wei1=1;
wei2=1;
}
void main(void)
{
EX0=1;
EX1=1;
IT0=1;
IT1=1;
EA=1;
while(1)
{
display();
}
}
void ext0(void) interrupt 0
{
display_buffer[1]++;
if(display_buffer[1]>9)
{
display_buffer[1]=0;
display_buffer[0]++;
if(display_buffer[0]>9)
{
display_buffer[0]=9;
display_buffer[1]=9;
}
}
}
void ext1(void) interrupt 2
{
display_buffer[0]=0;
display_buffer[1]=0;
} |