求教一位数码管,用定时器定时1秒,在P0口接数码管(BCD数码管),每秒显示的数字加一,如何用定时器延时编写,我只会用延时函数写,请大神帮忙修改成定时器定时1s,帮忙修改下程序
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code seg7ca[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
}; //0 1 2 3 4 5 6 7 8 9
void delay(uint t)
{
uint i,j;
for(i=0;i<t;i++)
{
for(j=0;j<124;j++);
}
}
void main()
{
while(1)
{
uchar i=0;
for(i=0;i<10;i++)
{
P0=seg7ca[i];
delay(1000);
}
}
}
|