又来写一遍,好烦啊。大家可以看一下图片和程序,按照正常的思路数字“0”在8*8点阵第一行应该是0x00,第二行应该是0x18,我按照这种思路用delay函数写过一遍结果是正常的,用定时器就出现上面这中情况,先谢谢大家了。
单片机源程序如下:
- #include<reg52.h>
- unsigned char lie[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
- unsigned char hang[3][8]={0x00,0x18,0x24,0x24,0x24,0x24,0x18,0x00, //数字0
- 0x00,0x3c,0x20,0x38,0x04,0x24,0x38,0x00, //数字5
- 0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00}; //数字8
- int a,i,j;
- void main()
- {
- TMOD=0x01;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- TR0=1;
- while(1)
- {
- P2=hang[j][i];
- P1=lie[i];
- i++;
- if(i==8)
- {
- i=0;
- }
- if(TF0==1)
- {
- TF0=0;
- a++;
-
- if(a==10)
- {
- a=0;
- j++;
-
- if(j==3)
- {
- j=0;
- }
- }
- }
- }
- }
复制代码
|