下面关于点阵的程序,不知道哪里出了问题,点阵显示混乱!这是一个关于循环显示数字的程序!
求大神帮忙找到问题!
#include "reg51.h"
#include "intrins.h"
#define uchar unsigned char
#define uint unsigned int
uchar code tableb[]=
{
0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00,
0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00,
0x00,0x4f,0x89,0x89,0x89,0x71,0x00,0x00,
0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00,
0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00,
0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00,
0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00,
0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00,
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00,
0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00
};
uchar i=0;
uchar dis_num=0;
uint t=0;
void main(void)
{
P0=0xfe;
TMOD=0x01;
TH0=0xff;
TL0=0x00;
EA=1;
ET0=1;
TR0=1;
while(1);
}
void Timer0(void) interrupt 1
{
TH0=0xff;
TL0=0x00;
P0=_crol_(P0,1);
P2=tableb[dis_num*8+i];
if(++i==10) i=0;
if(++t==1500)
{
t=0;
if(++dis_num==8) dis_num=0;
}
1,if(++i==10) i=0;改成if(++i==8) i=0;
2,P0=_crol_(P0,1);这一句有风险
这样试试:
新增全局变量uchar p=0xfe;
定时中断里P0=_crol_(p,1);
3,程序还可以这样改:
全局数组:code uchar seltab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
定时中断里P0=seltab[ i ] 当然,这个 i 有个范围:0~7
谢了,能显示了,还想问一句,为什么这句 P0=_crol_(P0,1); 有风险
一周热门 更多>