u010298834
王维来
2015-05-22 07:47

关于单片机旋转POV显示C语言程序的错误

  • 显示

#include
#define uint unsigned int
#define uchar unsigned char
uchar code buffer[]= //*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*//
{
0x10,0x60,0x02,0x8C,0x20,0x18,0x08,0x08,0x88,0x7F,0x88,0x08,0x28,0x18,0x08,0x00, //沈
0x04,0x04,0x7E,0x01,0x80,0x40,0x30,0x0C,0x03,0x00,0x3F,0x40,0x40,0x40,0x70,0x00,
0x00,0xFE,0x02,0x22,0xDA,0x06,0x00,0xFC,0x04,0x04,0x04,0x04,0x04,0xFC,0x00,0x00, //阳
0x00,0xFF,0x08,0x10,0x08,0x07,0x00,0xFF,0x41,0x41,0x41,0x41,0x41,0xFF,0x00,0x00,

0x80,0xFC,0x96,0xE5,0x84,0xFC,0x00,0x08,0xC8,0x49,0x4A,0xC8,0x08,0x08,0x00,0x00, //航
0x80,0x7F,0x02,0x4C,0x80,0x7F,0x80,0x60,0x1F,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,

0x10,0x0C,0x44,0x24,0x14,0x04,0x05,0x06,0x04,0x04,0x14,0x24,0x44,0x14,0x0C,0x00, //空
0x00,0x40,0x40,0x41,0x41,0x41,0x41,0x7F,0x41,0x41,0x41,0x41,0x40,0x40,0x00,0x00,
0x80,0xFC,0x96,0xE5,0x84,0xFC,0x00,0x08,0xC8,0x49,0x4A,0xC8,0x08,0x08,0x00,0x00, //航
0x80,0x7F,0x02,0x4C,0x80,0x7F,0x80,0x60,0x1F,0x00,0x00,0x3F,0x40,0x40,0x78,0x00,
0x40,0x40,0x42,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0x42,0x40,0x40,0x00, //天
0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, //大
0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,
0x40,0x30,0x11,0x96,0x90,0x90,0x91,0x96,0x90,0x90,0x98,0x14,0x13,0x50,0x30,0x00, //学
0x04,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x06,0x05,0x04,0x04,0x04,0x04,0x04,0x00,
};
uint i,sw=0,sd=0;
void delay(void)
{
EA=0;
TH0=0x78;TL0=0x78;
EA=1;
while(0==sw);
sw=0;
}
void display(uint kk) //显示函数,其中kk为定义第几个字
{
P1=0xff;P2=0xff;
for(i=0;i {
P1=buffer[i*2+kk*32];P2=buffer[1+i*2+kk*32];
P1=0xff;P2=0xff;
delay();
}
P1=0xff;P2=0xff;
}
void display_pov(int j)
{
if(j>=7)
j=0;
display(j);
j++;
}
void timer0(void) interrupt 1 using 1
{
TH1=0xf6;TL1=0x3a;
sd=1;
}

void intersvr0(void) interrupt 1 //定时器0中断
{

sw=1;
}
void timer0_init(void) //定时器初始化
{
TMOD=0x12;

TH0=0x78;TL0=0x78; //方式2定时(T0),定时每个帧的时间为278us
TH1=0xf6;TL1=0x3a; //方式1定时(T1),定时显示每个字的时间为5004us,其中包括两列的空操作
IT0=1;ET0=1;
IT1=1;ET1=1;
TR0=1;TR1=1;
}
void main()
{
uint k=0;
timer0_init();
EA=1;
while(1)
{

    if(sd==1)
    {
        display_pov(k);
        sd=0;
    }
}

}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换