2019-07-15 22:58发布
CrazyMCU 发表于 2013-8-19 11:03 没程序。这不是白问
CrazyMCU 发表于 2013-8-23 20:52 汇编那块我看不懂,为什么要用汇编啊?是卡死的话,大多是卡在死循环里吧while(!ram);,建议你一步一步来 ...
最多设置5个标签!
不好意思啊,失误
/*****************main.c*****************/
#include <STC12C5A60S2.h>
#include <aa.h>
#define uchar unsigned char
uchar data a[64];//={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uchar idata d[64];//={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
sbit st_cp=P3^3;
sbit st_clr=P3^2; //显示串口清除
uchar clock=0;
uchar ram=0;
void display();
void delay();
void asm(char asm)
{
#pragma asm
MOV P0,R7
MOV R3,#0FEH
LOOP1: MOV R5,#10
MOV R6,#255
LOOP: MOV P2,R3
MOV A,R3
RR A
MOV R3,A
DJNZ R6,LOOP
DJNZ R5,LOOP
#pragma endasm
}
void play()
{
uchar i=0;
TR0=0; //关T0
TH0=62869/256;
TL0=62869%256; //34ms
if(ram) //是否请求显存复制
{
for(i=0;i<64;i++) //显存复制
{
a=d;
}
ram=0;
}
if(!clock) //是否是锁显
{
display();
}
TR0=1; //开T0
}
void display()
{
uchar i,j,y,x;
P2=0xff;
P0=0;
x=1;
y=0;
for(i=0;i<8;i++) //第一层
{
y=8*i;
st_cp=0;
for(j=0;j<8;j++) //第一列
{
SBUF=(~a[7+y-j]);
while(!TI);
TI=0;
}
st_cp=1;
asm(x);
x=(x<<1);
}
P2=0xff;
P0=0;
}
void delay()
{
uchar j,k;
for(k=0;k<255;k++)
for(j=0;j<255;j++);
}
void delay1()
{
uchar j,k;
for(k=0;k<127;k++)
for(j=0;j<255;j++);
}
void main()
{
uchar i,j;
/*******t0初始化 显示 *********/
TMOD=0x01; //方式1
TH0=63869/256; //20ms
TL0=63869%256;
ET0=1; //T0允许
EA=1;
TR0=1; //T0运行
clock=0;
while(1)
{
for(i=0;i<64;i++)
{
d=a1;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a2;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a3;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a4;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a5;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a6;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a7;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a8;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a9;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a10;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(i=0;i<64;i++)
{
d=a11;
ram=1;
while(!ram);
}
delay();
delay();
delay();
for(j=0;j<3;j++)
{
for(i=0;i<64;i++)
{
d=a12;
ram=1;
while(!ram);
}
delay1();
for(i=0;i<64;i++)
{
d=a13;
ram=1;
while(!ram);
}
delay1();
for(i=0;i<64;i++)
{
d=a14;
ram=1;
while(!ram);
}
delay1();
for(i=0;i<64;i++)
{
d=a15;
ram=1;
while(!ram);
}
delay1();
for(i=0;i<64;i++)
{
d=a16;
ram=1;
while(!ram);
}
delay1();
}
}
}
void T_0() interrupt 1 //显示中断T0
{
play(); //显示动作函数
}
/****************aa.h****************/
#define uchar unsigned char
uchar xdata a2[64]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x18,0x24,0x7e,0x99,0x99,0x99,0xbd,0x66,0x18,0x24,0x7e,0x99,0x99,0x99,0xbd,0x66,0x18,0x24,0x7e,0x99,0x99,0x99,0xbd,0x66};
uchar xdata a1[64]={0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0,0xff,0};
都是类似的编码
c里没有循环左移,在keil里debug没事,到单片机里就不行了。
一周热门 更多>